I have always successfully used bluepill to demonize simple Ruby scripts. However, this time I have a script that also loads the Rails environment so that I can access my database connection for the Rails application and its corresponding models. The bluepill configuration that I use is no different from what I usually 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 problem 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 the same as with a bunch of my other scripts. However, this is the first time I am trying to demonize a script loading a Rails environment. I know that I can use the demons of ruby ββgems to make it work, but it does not monitor, and bluepill is able to perform both of these actions very well.
Am I missing something obvious here?
source share