Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delayed_job not picking up the rails environment

Followed this question about delayed_job and monit

Its working on my development machine. But whenever I try to run on production, it just dies with following on 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)>

And I m going to run in production env

ruby script/delayed_job start -e production

Still it errors out. I m noticing that this is due to the environment not set so that it tries to pick up the development environment.

/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)

Why isn't the environment parameter not set properly?

like image 720
Autodidact Avatar asked Sep 06 '09 19:09

Autodidact


3 Answers

Just use

ruby RAILS_ENV=production script/delayed_job start
like image 134
punkrats Avatar answered Sep 25 '22 20:09

punkrats


I might be worng here, but are you using this gist as script/delayed_job? If so, it doesn't need the "-e" - simply calling script/delayed_job start production or chaning the line that starts with ENV['RAILS_ENV'] (replacing "development" with "production") should be sufficient.

If you still get errors from MySQL afterwards, you should double check your username and password.

like image 35
cite Avatar answered Sep 24 '22 20:09

cite


Just to help people finding this question and the old answers: the script doesn't accept the environment parameter any more: https://github.com/collectiveidea/delayed_job/issues/7

like image 30
Kyberias Avatar answered Sep 26 '22 20:09

Kyberias