2

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

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

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).

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.

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

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:

/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.

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

Cheers.

4

1 回答 1

0

在部署服务器上使用rvm 时, rvm1-capistrano3可以节省您的时间。您可以将此模板用作操作指南

于 2014-09-11T14:53:02.197 回答