delayed_job没有拿起铁轨环境

时间:2009-09-06 19:23:53

标签: ruby-on-rails daemon delayed-job

关注delayed_job and monit

这个问题

它在我的开发机器上工作。但每当我尝试在生产中运行时,它就会因为在delayed_job.log

上跟随而死亡
*** Starting job worker delayed_job host:mail.welcometonewnepal.com pid:356
#<Mysql::Error: Access denied for user 'root'@'localhost' (using password: YES)>
*** Starting job worker delayed_job host:mail.welcometonewnepal.com pid:441
#<Mysql::Error: Access denied for user 'root'@'localhost' (using password: YES)>
*** Starting job worker delayed_job host:mail.welcometonewnepal.com pid:448
#<Mysql::Error: Access denied for user 'root'@'localhost' (using password: YES)>

我将在生产环境中运行

ruby script/delayed_job start -e production

仍然出错了。我注意到这是由于没有设置环境以致它试图获得开发环境。

/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:365:in `read': No such file or directory - /home/millisami/rails_apps/wnn_finale/config/environments/-e.rb (Errno::ENOENT)

为什么环境参数设置不正确?

4 个答案:

答案 0 :(得分:4)

只需使用

ruby RAILS_ENV=production script/delayed_job start

答案 1 :(得分:3)

我可能会在这里工作,但您使用this gist作为脚本/ delayed_job吗?如果是这样,它不需要“-e” - simply calling script/delayed_job start production或者使用以ENV['RAILS_ENV']开头的行(用“生产”替换“开发”)就足够了。

如果您之后仍然从MySQL收到错误,则应仔细检查您的用户名和密码。

答案 2 :(得分:1)

只是为了帮助人们找到这个问题和旧答案:脚本不再接受环境参数:https://github.com/collectiveidea/delayed_job/issues/7

答案 3 :(得分:0)

试试script/delayed_job start -- production。我不认为你将环境传递给DJ的方式与script/server相同。这个答案特定于我们使用的delayed_job文件,我正在寻找它的要点。

编辑:这是我们使用的文件的gist

相关问题