I am able to monitor thin with monit, but when I restart it with monit through capistrano, it crashes.

I created a script to start thin with the yml:

chdir: /home/jack/apps/myapp/current
environment: production
address: 0.0.0.0
port: 3000
timeout: 30
log: log/thin.log
pid: tmp/pids/thin.pid
max_conns: 1024
max_persistent_conns: 512
require: []
wait: 30
servers: 1
daemonize: true

And I use this to start and stop thin with monit:

check process thin3000
  with pidfile /home/jack/apps/myapp/shared/pids/thin.3000.pid
  start program = "/usr/local/bin/thin -C /etc/thin/thin.yml start -o 3000"
  stop program = "/usr/local/bin/thin -C /etc/thin/thin.yml stop -o 3000"
  if totalmem > 200.0 MB for 5 cycles then restart
  if failed port 3000 then restart
  if cpu usage > 95% for 3 cycles then restart
  if 5 restarts within 5 cycles then timeout
group thin

My capistrano restart just looks like this:

  task :restart do
    sudo "monit restart thin3000"
  end

This command works fine when I am logged into the server with ssh, but when I try it with capistrano, it looks like 3 thin servers get started. The thin3000 process status goes to "connection failed" and thin soon crashes. I'm not sure what's going on.

link|improve this question
what happens if you change the restart task to run "sudo monit restart thin3000" – pablo Nov 18 '11 at 7:43
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.