views:

74

answers:

2

Can't seem to get delayed job to get running with monit. here is my delayed_job.monitrc file..

check process delayed_job with pidfile /var/www/app/shared/pids/delayed_job.pid
  start program = "cd /var/www/myapp/current && script/delayed_job start RAILS_ENV=production"
                as uid deploy and gid www-data
  stop program =  "cd /var/www/myapp/current && script/delayed_job stop RAILS_ENV=production"
           as uid deploy and gid www-data
  if mem usage > 20% for 5 cycles then alert
  if mem usage > 30% for 5 cycles then restart

I have tried doing a straight command as well and this won't even work without monit. I have to be in the current directory for the script/delayed_job start to function, or it throws an error like..

/var/www/myapp/current/script/delayed_job start RAILS_ENV=production

/usr/local/lib/ruby/1.8/fileutils.rb:243:in `mkdir': Permission denied - log (Errno::EACCES)
    from /usr/local/lib/ruby/1.8/fileutils.rb:243:in `fu_mkdir'
    from /usr/local/lib/ruby/1.8/fileutils.rb:217:in `mkdir_p'
    from /usr/local/lib/ruby/1.8/fileutils.rb:215:in `reverse_each'
    from /usr/local/lib/ruby/1.8/fileutils.rb:215:in `mkdir_p'
    from /usr/local/lib/ruby/1.8/fileutils.rb:201:in `each'
    from /usr/local/lib/ruby/1.8/fileutils.rb:201:in `mkdir_p'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/buffered_logger.rb:51:in `initialize'
    from /var/www/myapp/releases/20101001032406/config/initializers/dj.rb:4:in `new'
    from /var/www/myapp/releases/20101001032406/config/initializers/dj.rb:4
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:147:in `load_without_new_constant_marking'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:147:in `load'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:622:in `load_application_initializers'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:621:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:621:in `load_application_initializers'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:176:in `process'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
    from /var/www/myapp/current/config/environment.rb:10
    from /var/www/myapp/current/script/delayed_job:3:in `require'
    from /var/www/myapp/current/script/delayed_job:3

Monit status just says execution failed.

A: 

I guess that that log directory should be in /var/www/myapp/current/ and DJ is trying to mkdir before writing to it. And most probably, the user 'deploy' do not have the permission to write to /var/www/myapp/current.

Vijay Dev
Hmm..no, deploy own currrent directory
badnaam
I accepted the answer though it wasn't exactly the case, it led me to the right direction. thanks
badnaam
A: 

The issue was I had the followoing in the DJ initializer, to have DJ log to regular rails logs..which doesn't happen btw. It got resolved once I commented it.

Delayed::Worker.logger = ActiveSupport::BufferedLogger.new("log/ {Rails.env}_delayed_jobs.log##", Rails.logger.level) Delayed::Worker.logger.auto_flushing = 1

badnaam