Unicorn 不是由 upstart 脚本运行的。
rvm 1.25.23 ruby 2.1.1 rails 4.1
配置/部署.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
unicorn 成功上线。
如果在/etc/init/depl-web-1.conf exec 行添加端口
exec 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
最佳答案
我最终做了一些类似于 Denis 的事情,除了每个 RVM 文档使用了 Ruby 包装器。这真的很烦人,但根据 top -c
和 shift-M
它正在工作。写半详细,因为我希望这对其他人有所帮助。
我的设置是:Digital Ocean、Ubuntu 14.10、Rails 4.0.x、Ruby 2.0.x、RVM 1.26.10。由于我使用的是Passenger 5+Nginx,因此我的Procfile 仅用于后台作业。部署用户是“rails”。我有一个名为“ruby-2.0.0-p598@rockin”的 gemset 用于我的名为“rockin”的应用程序,因为我在盒子上运行了多个应用程序。
添加绝对值 PATH
bundle 对我不起作用。
这是我所做的:
rvm alias create rockin ruby-2.0.0-p598@rockin
RAILS_ENV=production
rvmsudo foreman export upstart /etc/init -a rockin -u rails
tail -f /var/log/upstart/rockin-worker-1.log
rockin-worker-1.conf
.由于大部分内容都已格式化并具有我需要的内容,因此我使用上面创建的包装器更改了 exec 行以真正指向 bundle。start on starting rockin-worker
stop on stopping rockin-worker
respawn
env PORT=5000
env RAILS_ENV='production'
setuid rails
chdir /home/rails/rockin
exec /usr/local/rvm/wrappers/rockin/bundle exec rake environment resque:work QUEUE=*
sudo start rockin-worker
top -c
来仔细检查顶部和 shift-M
.我的 resque worker 启动并进入等待模式。完美的。 这应该适用于使用 rvm 和其他后台工作人员(如 sidekiq)的任何人。
对于任何说 PATH 可行的人,我都尝试了
which bundle
和 whereis bundle
从我的应用程序的根目录,并将这些路径用于 .env 文件。两者都不起作用,并且都导致日志提示 /bin/sh: 1: exec: bundle: not found
.
关于ruby-on-rails - Foreman rvm upstart 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23307503/