问题
When I launch my app in production to test it before rolling out to the server, I noticed that one of my database operations which is called by Resque.enqueue(worker) is performed on the WRONG database! development.sqlite3 instead of production.sqlite3. I'm running both the server and resque with zero configuration files. There must be some way to run redis or resque in the correct environment.
defaults: &defaults
host: localhost
port: 6379
development:
<<: *defaults
test:
<<: *defaults
staging:
<<: *defaults
production:
<<: *defaults
This redis config file I found may hold the key, but redis doesn't like it, saying
*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 1
>>> 'defaults: &defaults'
Bad directive or wrong number of arguments
回答1:
Did you start resque worker in the production environment ? You can do it like this,
$ RAILS_ENV=production QUEUE=* rake resque:work
来源:https://stackoverflow.com/questions/12098661/resque-is-writing-to-the-development-database-even-when-run-from-a-server-in-pro