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和production.log清空
如果您进入应用程序的目录并手动运行命令
bundle exec unicorn_rails -c /home/deployer/apps/depl/current/config/unicorn.rb -E production
独角兽成功启动。
如果在/etc/init/depl-web-1.conf执行行中添加端口
执行bundle exec unicorn_rails -p $PORT -c
/home/deployer/apps/depl/current/config/unicorn.rb -E production
错误:
/bin/sh: 1: exec: bundle: not found
我使用RVM。
which bundle
/home/deployer/.rvm/gems/ruby-2.1.1/bin/bundle
which rvm
/home/deployer/.rvm/bin/rvm