@maikel and @gnollet I am at the same issue you solved a few weeks ago, trying to get monit to run the /script/delayed_job
process. For some reason, possibly unwisely, I changed the app name to ofn_america
throughout the deploy script, but I don’t imagine that should make much difference.
The script generated by ansible via the /roles/common/templates/monit.j2
template looks like this:
check process ofn_america_dj_worker_0
with pidfile /home/ubuntu/apps/ofn_america/current/tmp/pids/delayed_job.0.pid
start program = "/bin/bash -c 'RAILS_ENV=staging /home/ubuntu/.rbenv/shims/ruby /home/ubuntu/apps/ofn_america/current/script/delayed_job -i 0 start'"
as uid ubuntu and gid ubuntu
with timeout 120 seconds
stop program = "/bin/bash -c 'RAILS_ENV=staging /home/ubuntu/.rbenv/shims/ruby /home/ubuntu/apps/ofn_america/current/script/delayed_job -i 0 stop'"
as uid ubuntu and gid ubuntu
with timeout 120 seconds
if mem is greater than 250.0 MB for 3 cycles then restart
And the process will start (sending emails) if I run the CLI command directly:
/bin/bash -c 'RAILS_ENV=staging /home/ubuntu/.rbenv/shims/ruby /home/ubuntu/apps/ofn_america/current/script/delayed_job -i 0 start'
And /home/ubuntu/apps/myapp/current/tmp/pids/delayed_job.0.pid
exists (until I stop the process).
-rwxr-xr-x 1 ubuntu ubuntu 175 Nov 6 01:35 delayed_job
I notice you reference a file called delayed_job.sh
above which in my server contains:
#!/usr/bin/env bash
export HOME="/home/ubuntu"
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
$HOME/apps/ofn_america/current/script/delayed_job $@
I can also, from within the script
dir start the process with CLI:
sudo bash delayed_job.sh -i 0 start
And again, tmp/pids/delayed_job.0.pid
exists and emails are sent.
I restart monit sudo service monit restart
: * Restarting daemon monitor monit
.
Waited a few minutes and even tried raising timeout to 240
, but it’s not nearly that slow when starting delayed jobs fro the CLI.
Any thoughts?
Posted here as well.