From: Colin Shield Date: 2008-07-10T03:01:46+09:00 Subject: Re: one background process ara.t.howard wrote: > On Jul 7, 2008, at 1:02 PM, Colin Shield wrote: if you want to run only one > instance run it by hand via cron as the docs show Thanks for the reply. I've got it all working nicely in production now. We use monit in production. The config is under source control so we can deploy changes with cap. I wrote some monit config to run a bj process. This may help somebody. ##### BJ #### # BJ is a ruby script that manages background processes. check process bj with pidfile /mnt/app/shared/pids/bj.pid start program = "/bin/bash /mnt/app/current/script/bj.sh start production &" stop program = "/bin/bash /mnt/app/current/script/bj.sh stop" I wrote a bash wrapper (bj.sh) as monit uses pidfiles. #!/bin/bash case $1 in start) echo $$ > /mnt/app/shared/pids/bj.pid; exec 2>&1 /usr/bin/ruby1.8 /mnt/app/current/script/bj run --forever --redirect=/mnt/app/shared/log/bj.log --rails_env=$2 --rails_root=/mnt/app/current 1>/mnt/app/shared/log/bj.log ;; stop) kill `cat /mnt/app/shared/pids/bj.pid`; rm /mnt/app/shared/pids/bj.pid ;; *) echo "usage: bj.sh {start |stop}" ;; esac -- Posted via http://www.ruby-forum.com/.