使用monit似乎无法延迟工作。这是我的delayed_job.monitrc文件..
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
我也尝试过直接命令,如果没有monit,这甚至都行不通。我必须在脚本/ delayed_job开始运行的当前目录中,否则会抛出类似的错误。
/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状态只表示执行失败。
答案 0 :(得分:0)
我想那个日志目录应该在/ var / www / myapp / current /中,并且DJ在写入之前尝试使用mkdir。最有可能的是,用户'deploy'没有写入/ var / www / myapp / current的权限。
答案 1 :(得分:-1)
问题是我在DJ初始化程序中有以下内容,让DJ登录到常规rails日志(这不会发生btw)。一旦我评论它就解决了。
Delayed::Worker.logger = ActiveSupport::BufferedLogger.new("log/{Rails.env}_delayed_jobs.log##", Rails.logger.level)
Delayed::Worker.logger.auto_flushing = 1