Question

I need help for my capistrano deployment.

All the process work fine until it reach the forever proccess launch. The forever proccess is launched, but capistrano process remains on that task.

This is my task:

  desc 'Start application'
  task :start do
    on roles(:app), in: :sequence, wait: 5 do
      execute "cd #{current_path} && NODE_ENV=#{fetch(:application_env)} PORT=#{fetch(:application_port)} forever start -l #{current_path}/logs/logs.log -e #{current_path}/logs/err.log -o #{current_path}/logs/out.log -a #{current_path}/app.js", raise_on_non_zero_exit: false
    end
  end

I already tried the "> /dev/null 2>&1" and " &" options.

I need just the forever proccess hang up. Any help will be appreciated.

Was it helpful?

Solution

An old post I know but here's my take on it

Instead of putting NODE_ENV in your task, set a :default_env option.

set :default_env, { NODE_ENV: "test" }

Then you can use the symbol with exec. execute :forever, "other options"

I've also found that there are quirks with paths in forever so, especialy when trying to set a pid file. Try using the -p option to set the current path and then you don't need to add current path except on pidFile it seems.

Putting it all together

set :default_env, {NODE_ENV: fetch(:application_env), ...}

desc 'Start application'
task :start do
  on roles(:app), in: :sequence, wait: 5 do
    execute :forever, "start -p #{release_path} -l logs/logs.log -e logs/err.log -o logs/out.log -a --pidFile #{release_path}/pidfile.pid app.js"
  end
end

EDIT: as soon as I hit save I remembered I had to mention that I am talking about Capistrano 3 in case you were not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top