0

How can I pass the --env variable "staging or production" in the execute statement my Capistrano tasks ?

  def restart_app
    within current_path do
      execute :pm2, :restart, fetch(:app_command)
    end
  end

  def start_app
    within current_path do
      execute :pm2, :stop, fetch(:app_command)
    end
  end

currently once started , process.env.NODE_ENV is undefined

  • got a clue reading the following post http://stackoverflow.com/questions/19452983/capistrano-3-execute-within-a-directory –  Feb 16 '17 at 08:14

1 Answers1

0

I am using the within current path and I should change the execute command to "retain all the niceties of within(), with(), default_env, etc, while still keeping the natural string syntax:"

within current_path do execute *%w[ pm2 restart hello.js --env staging ] end