【问题标题】:Proper deployment of a Rails app with Mina and Foreman使用 Mina 和 Foreman 正确部署 Rails 应用程序
【发布时间】:2014-02-18 21:32:08
【问题描述】:

出于生产目的,我需要运行三个进程。这是我的 procfile,我使用 Foreman 来启动它们:

web: bundle exec rails s Puma -p $PORT
queuing: bundle exec clockwork clock.rb
workers: bundle exec rake resque:workers

对于部署,我使用的是 Mina。在部署任务结束时启动 Foreman 的适当方法是什么?目前我是这样开始的:

desc "Deploys the current version to the server."
  task :deploy => :environment do
    deploy do
      invoke :'git:clone'
      invoke :'deploy:link_shared_paths'
      invoke :'bundle:install'
      invoke :'rails:db_migrate'
      invoke :'rails:assets_precompile'

      to :launch do
        queue "touch #{deploy_to}/tmp/restart.txt"
        queue "bundle exec foreman start"
      end
   end
 end

...但我认为这不是正确的方法,因为“mina deploy”命令从未成功退出,本地控制台只是开始输出这些进程正在执行的操作。

问题二:如何在单独的文件中分别初始化这三个进程中的每一个的日志记录?

当其中一个崩溃时,如何防止杀死所有这三个进程?进程崩溃时如何让进程重启?

谢谢!

【问题讨论】:

    标签: ruby-on-rails ruby foreman mina


    【解决方案1】:

    好的,这是 3 个问题。

    1) 我认为您想将领班进程与终端分离。这样,即使您与服务器断开连接,部署过程也将完成,工头进程将继续运行。 nohup 非常适合,例如这将启动您的应用并将所有日志通过管道传输到server.log 文件:

    nohup foreman start > server.log 2>&1 &

    2) AFAIK,工头不允许你这样做。您可能应该使用另一个进程管理服务(例如 systemd、upstart)。值得庆幸的是,foreman 让您可以轻松地将配置导出为不同的流程管理格式 (http://ddollar.github.io/foreman/#EXPORTING)。

    3) 同样,您可能希望分离您的进程并通过 upstart、systemd 等单独管理它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-20
      • 1970-01-01
      相关资源
      最近更新 更多