【发布时间】:2015-03-01 19:42:52
【问题描述】:
我已经在其他几个问题/Github 问题中看到了这个问题,但他们未能提供足够的信息来解决问题。
错误:
bash: bundle: command not found
SSHKit::Runner::ExecuteError: Exception while executing as my-user@my-IP-address: cd /path-to-my-app/current ; bundle exec unicorn -D -c config/unicorn.rb -E production exit status: 127
cd /path-to-my-app/current ; bundle exec unicorn -D -c config/unicorn.rb -E production stdout: Nothing written
cd /path-to-my-app/current ; bundle exec unicorn -D -c config/unicorn.rb -E production stderr: bash: bundle: command not found
我在我的 rails 应用上使用了最新版本的 Capistrano。具体来说,它是带有宝石capistrano-rails 和capistrano-rvm 的Rails 4.2.0 应用程序。
我有一个非常标准的config/unicorn.rb 文件,这是我在登录服务器时启动独角兽的方式。我首先杀死当前的PID:
kill -9 PID
然后我开始独角兽:
bundle exec unicorn -D -c /path-to-my/config/unicorn.rb -E production
这很好用,但显然我需要 capistrano 来做到这一点,所以我的 deploy.rb 文件中基本上有这些任务,但是我得到了上面提到的错误。这是我在deploy.rb 中的两个任务:
namespace :deploy do
namespace :unicorn do
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute "kill -s USR2 `cat /path-to-my/tmp/pids/app-name.pid`"
end
end
desc 'Start unicorn'
task :start do
on roles(:app), in: :sequence, wait: 5 do
execute "cd #{current_path} ; bundle exec unicorn -D -c config/unicorn.rb -E production"
end
end
end
end
我有一个类似的任务来重新启动 DelayedJob,这会引发相同的错误。命令是execute "cd #{current_path} ; RAILS_ENV=production bin/delayed_job -n2 restart"。就像我上面提到的,当使用我的用户(我用于 Capistrano 的同一用户)登录服务器时,所有这些任务都按预期工作。
其他所有内置任务都非常适合 Capistrano,例如预编译资产、迁移我的数据库等。这是我添加的自定义任务导致错误。
如果我可以添加任何内容来帮助解决问题,请告诉我。
【问题讨论】:
-
你在服务器上使用的是 rvm 还是 rbenv?
标签: ruby-on-rails ruby-on-rails-4 capistrano unicorn