Capistrano v3任务无法启动unicorn服务器,错误“eval:bundle not found”

时间:2023-01-31 18:25:03

I'm using Capistrano v3 to deploy a rails 4 app to a VPS using unicorn with nginx.

我正在使用Capistrano v3使用带有nginx的独角兽将rails 4应用程序部署到VPS。

Following the capistrano most recent official documentation, I managed to set up everything related to the deployment itself:

根据capistrano最新的官方文档,我设法设置了与部署本身相关的所有内容:

I use the gems 'capistrano', 'capistrano-bundler', 'capistrano-rails' and 'capistrano-rvm' and when I do cap production deploy everything seems to work without any error message (the repository is pulled from github and copied on the server, assets are precompiled and so on).

我使用宝石'capistrano','capistrano-bundler','capistrano-rails'和'capistrano-rvm',当我进行封装生产部署时,一切似乎都没有任何错误消息(存储库是从github中提取并复制的服务器,资产是预编译的等等)。

At this point if I connect to the sever via ssh and type /etc/init.d/unicorn start the server starts as expected, serving my rails app.

此时,如果我通过ssh连接到服务器并输入/etc/init.d/unicorn,则启动服务器按预期启动,为我的rails应用程序提供服务。

However, I created a task to automate this with capistrano v3 that looks like:

但是,我创建了一个任务,使用capistrano v3自动执行此操作,如下所示:

namespace :unicorn do

  desc 'Start Unicorn'
  task :start do
    on roles(:app) do
      within current_path do
        execute "/etc/init.d/unicorn start"
      end
    end
  end

  desc 'Stop Unicorn'
  task :stop do
    on roles(:app) do
      within current_path do
        execute "/etc/init.d/unicorn stop"
      end
    end
  end

end

But whenever I try capistrano deploy unicorn:start I get the following error:

但每当我尝试capistrano部署独角兽:开始我得到以下错误:

/etc/init.d/unicorn: 1: eval: bundle: not found
cap aborted!
/etc/init.d/unicorn start stdout: Nothing written
/etc/init.d/unicorn start stderr: Nothing written

What's even stranger is that when I start unicorn manually and then do cap production unicorn:stop it works seamlessly.

更奇怪的是,当我手动启动独角兽然后制作独角兽制帽时:停止无缝工作。

I suspected some differences in available environment variables when logging in via ssh so I configured 'rvm_bin_path', 'path' and 'gem_path' to be the same as on server but I still get the same error.

我通过ssh登录时怀疑可用环境变量存在一些差异所以我将'rvm_bin_path','path'和'gem_path'配置为与服务器上的相同但我仍然得到相同的错误。

I'm running out of ideas, anyone knows what could cause this?

我的想法已经不多了,有谁知道是什么原因造成的?

Cheers.

1 个解决方案

#1


0  

When rvm is used on the deploy server rvm1-capistrano3 saves you. You can use this template as how-to

当在部署服务器上使用rvm时,rvm1-capistrano3会保存您。您可以将此模板用作操作方法

#1


0  

When rvm is used on the deploy server rvm1-capistrano3 saves you. You can use this template as how-to

当在部署服务器上使用rvm时,rvm1-capistrano3会保存您。您可以将此模板用作操作方法