【问题标题】:Installing and starting daemon script via Capistrano 3通过 Capistrano 3 安装和启动守护程序脚本
【发布时间】:2016-01-31 04:47:18
【问题描述】:

我已经尝试了好几天了,但现在没有成功。我正在使用 Capistrano 3 在我的生产服务器上部署我的 Ruby on Rails 4 代码。

在部署过程结束时,我想重新启动我的守护程序脚本,我将通过以下命令手动完成:

RAILS_ENV=production bundle exec ruby script/my_daemon restart

在我的 Capistrano 3 食谱 (config/deploy.rb) 上,我尝试了几种不同的设置,但都没有奏效。

namespace :deploy do
  desc 'Restart application'

  task :restart do
invoke 'unicorn:restart'
  end
  after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do

      within release_path do
        execute :rake, 'tmp:cache:clear'

        # Daemons
        # This ends up with an error
        execute :bundle, :exec, :ruby, "RAILS_ENV=production /var/www/MY_APP/current/script/my_daemon restart;"

        # This starts the daemon, but in development environment
        execute :bundle, :exec, :ruby, "/var/www/MY_APP/current/script/my_daemon restart RAILS_ENV=production;"

        # This also starts the daemon, but in development environment
        execute :bundle, :exec, :ruby, "/var/www/MY_APP/current/script/my_daemon restart;"
      end
    end
  end
end

有人可以帮我编写正确的方法来在生产环境中重新启动我的守护进程吗?谢谢。

【问题讨论】:

标签: ruby-on-rails ruby capistrano3


【解决方案1】:

尝试通过 capistrano dsl 设置环境

within release_path do
  with rails_env: :production do
    execute :bundle, :exec, :ruby, "#{current_path}/script/my_daemon restart"
  end
end

【讨论】:

    猜你喜欢
    • 2013-12-05
    • 2012-07-25
    • 2014-11-14
    • 2012-08-05
    • 1970-01-01
    • 2011-09-07
    • 1970-01-01
    • 2013-06-24
    • 2010-11-28
    相关资源
    最近更新 更多