tmartin314
tmartin314

Reputation: 4171

Deploying Rails 4 with Capistrano foreman environment

I found some issues with a worker running in the development environment and need to customize the foreman export task to set the ENV to production somehow:

  task :export_worker, roles: :worker do
    foreman_export = "foreman export --app #{application} --user #{user} --concurrency worker=3,worker_slow=2,clock=1 --log #{shared_path}/log upstart /etc/init"
    run "cd #{current_path} && #{sudo} #{bundle_cmd} exec #{foreman_export}"
  end

Anyone know how I can set it to production when it runs?

Upvotes: 0

Views: 786

Answers (1)

conarro
conarro

Reputation: 86

Foreman has an environment option that can be used to load custom .env files. You could try using that to set the environment to production.

For example, if you had a development.env file containing the following:

RAILS_ENV=development

You could get Foreman to load it like this:

foreman export -e development.env -c worker=3,worker_slow=2,clock=1 upstart /etc/init

Then if you need to reference the environment in your Procfile (example assumes sidekiq worker):

worker: bundle exec sidekiq --environment $RAILS_ENV

Heroku has a nice article on setting up a .env file for use with Foreman.

Upvotes: 3

Related Questions