dmytro/nagira

init.d function `get_pid` using `ps -C` failing to identify nagira process

Closed this issue · 6 comments

echo $(ps -C ruby -o pid,cmd | awk '$2 ~ /^\/usr.*bin\/nagira *$/ {print $1}')

running
root@nagios:~# echo $(ps -C ruby -o pid,cmd | awk '$2 ~ /^\/usr.*bin\/nagira *$/ {print $1}')
returns nothing..

The process is being spawned, but the get_pid function is failing.

# sherlock
OS=Linux
MACH=x86_64
KERNEL=3.13.0-48-generic
DISTRIBUTION=debian
FAMILY=debian
DERIVATIVE=Ubuntu
RELEASE=14.04
CODENAME=trusty

Code switched to

echo $(ps aux| grep nagira| grep ruby| awk '{print $2}')
root@nagios:~# service nagira start
Starting Sinatra Nagira services:    [OK]
Process Sinatra Nagira services is running with PID: 2185

root@nagios:~# service nagira status
Process Sinatra Nagira services is running with PID: 2185

root@nagios:~# service nagira stop
Shutting down Sinatra Nagira services:    OK

This is a duplicate of #30 I know about the problem on some systems, but could not reproduce it.

mig5 commented

This fix worked for me on Debian 7.

I would use this solution, if it was a bit more reliable.

If you just grep for nagira and ruby, there could be other process that match. For example, if your project happen to be in ~/ruby/nagira and you leave running vi ~/ruby/nagira/<whatever>. I've seen some very serious failures with similar checks.

If you could send me output of the following command on your system, with nagira running, that could help:

ps -C ruby -o pid,cmd

@shadowbq @mig5

mig5 commented
root@monitor1:~# ps -C ruby -o pid,cmd
  PID CMD
root@monitor1:~# ps aux | grep nagira | grep -v grep
nagios   29686  1.0  6.2 269620 128968 ?       Sl   Oct08   1:10 /usr/bin/ruby1.9.1 /usr/local/bin/nagira

Ooook! Now I understand your problem. You ruby binary is not ruby but ruby1.9.1 I'll think how to fix it.

Thank you for providing that info. 👍

Resolved by e524721

New version 0.4.2 tagged and gem pushed.