God starts too many processes God starts too many processes ruby ruby

God starts too many processes


It seems like god is trying to follow bbundle and not stalk. You need to let god know where to find the PID of the actual process you want to follow with w.pid_file. You might also need to tell it how to kill the process, if a standard kill won't do the trick. For that you can use w.stop_signal for a different signal (as simonmenke suggested) or w.stop for a whole other command.

The log file should shed more light on what's going on. Call god -D to print it to stdout or god -l /var/log/god.log.


Stacker stops when it receives a INT signal (not a TERM signal).Try adding a stop signal:

# ...w.stop_signal = 'INT'# ...


This should help with your question: Monitor a Rake task with God.

In short, you can store a reference to your PID file in your god config:

 God.watch do |w|   w.dir = "#{rails_root}"   w.name = "my_task"   w.interval = 10.seconds   w.pid_file = "#{rails_root}/tmp/pids/#{w.name}.pid"   w.env = {"RAILS_ENV"=>rails_env, 'PIDFILE' => w.pid_file}   w.start = "bundle exec rake my_task &"   ... end

and in your running process you write to this file your PID (in this example, rake):

 task :my_task => :environment do   File.open(ENV['PIDFILE'], 'w') { |f| f << Process.pid } if ENV['PIDFILE']   Model.perform_task! end

We pass the path of the PID file god is watching to the process that is actually being watched and that writes its PID to that file (which god then monitors). Hope this helps.