Unicorn not runs by upstart script.
rvm 1.25.23 ruby 2.1.1 Rails 4.1
config/deploy.rb
desc 'Foreman init'
task :foreman_init do
on roles(:all) do
foreman_temp = "/home/deployer/tmp/foreman"
execute "mkdir -p #{foreman_temp}"
execute "ln -s #{release_path} #{current_path}"
within current_path do
execute "cd #{current_path}"
execute :bundle, "exec foreman export upstart #{foreman_temp} -a #{application} -u deployer -l /home/deployer/apps/#{application}/log -d #{current_path}"
end
sudo "mv #{foreman_temp}/* /etc/init/"
sudo "rm -r #{foreman_temp}"
end
end
/etc/init/depl-web-1.conf
start on starting depl-web
stop on stopping depl-web
respawn
env PORT=5000
setuid deployer
chdir /home/deployer/apps/depl/current
exec bundle exec unicorn_rails -c /home/deployer/apps/depl/current/config/unicorn.rb -E production
/log/upstart/depl-web-1.log and production.log clear
if you go to the application's directory and manually run the command
bundle exec unicorn_rails -c /home/deployer/apps/depl/current/config/unicorn.rb -E production
Unicorn successfully launched.
If in /etc/init/depl-web-1.conf exec line add port
exec bundle exec unicorn_rails -p $PORT -c
/home/deployer/apps/depl/current/config/unicorn.rb -E production
error:
/bin/sh: 1: exec: bundle: not found
i use rvm
which bundle
/home/deployer/.rvm/gems/ruby-2.1.1/bin/bundle
which rvm
/home/deployer/.rvm/bin/rvm
I manually edited.
start on starting depl-web
stop on stopping depl-web
respawn
env PORT=5000
env RVM_SHELL=/home/deployer/.rvm/bin/rvm-shell
env RUBY_VERSION="2.1.5"
setuid deployer
script
chdir /home/deployer/apps/depl/current
$RVM_SHELL $RUBY_VERSION -c 'bundle exec unicorn_rails -c /home/deployer/apps/depl/current/config/unicorn.rb -E production'
end script