I've always used bluepill successfully to daemonize simple Ruby scripts. This time however, I have a script that's also loading a Rails environment so I can access my database connection for the Rails app and its respective models. The bluepill config I use is no different than what I normally do:
Bluepill.application("myapp", :foreground => true, :log_file => "/tmp/bluepill.log") do |app|
app.process("myapp_process") do |process|
process.start_command = "/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby /media/apps/myapp/current/lib/async/myscript.rb"
process.pid_file = "/media/apps/myapp/current/tmp/pids/myscript.pid"
process.daemonize = true
process.stdout = "/var/log/myapp/media.log"
process.stderr = "/var/log/myapp/media_error.log"
process.working_dir = "/tmp"
process.stop_command = "kill -QUIT {{PID}}"
process.start_grace_time = 15.seconds
end
end
The main issue is this error:
Failed to signal process 16096 with code 0: No such process
If I do not load the Rails environment using this:
require File.expand_path("/media/apps/myapp/current/config/environment")
This will work as it does with a bunch of my other scripts. This is the first time I'm trying to daemonize a script that loads the Rails environment, however. I know I can use the ruby gem Daemons to get this to work, but that doesn't do monitoring and bluepill is capable of doing both really well.
Am I missing something obvious here?