Anjan
Anjan

Reputation: 1633

Upstart tracking wrong PID of Bluepill

I have bluepill setup to monitor my delayed_job processes.

Using Ubuntu 12.04.

I am starting and monitoring the bluepill service itself using Ubuntu's upstart. My upstart config is below (/etc/init/bluepill.conf).

description "Start up the bluepill service"

start on runlevel [2]
stop on runlevel [016]

expect fork
exec sudo /home/deploy/.rvm/wrappers/<app_name>/bluepill load /home/deploy/websites/<app_name>/current/config/server/staging/delayed_job.bluepill

# Restart the process if it dies with a signal
# or exit code not given by the 'normal exit' stanza.
respawn

I have also tried with expect daemon instead of expect fork. I have also tried removing the expect... line completely.

When the machine boots, bluepill starts up fine.

$ ps aux | grep blue
root      1154  0.6  0.8 206416 17372 ?        Sl   21:19   0:00 bluepilld: <app_name>

The PID of the bluepill process is 1154 here. But upstart seems to be tracking the wrong PID.

$ initctl status bluepill
bluepill start/running, process 990

This is preventing the bluepill process from getting respawned if I forcefully kill bluepill using kill -9.

Moreover, I think because of the wrong PID being tracked, reboot / shutdown just hangs and I have to hard reset the machine every time.

What could be the issue here?

Upvotes: 5

Views: 800

Answers (1)

Sigi
Sigi

Reputation: 1864

Clearly, upstart tracks the wrong PID. From looking at the bluepill source code, it uses the daemons gem to daemonize, which in turn forks twice. So expect daemon in the upstart config should track the correct PID -- but you've already tried that.

If it is possible for you, you should run bluepill in the foreground, and not use any expect stanza at all in your upstart config.

From the bluepill documentation:

Bluepill.application("app_name", :foreground => true) do |app|
  # ...
end

will run bluepill in the foreground.

Upvotes: 0

Related Questions