以Deamon身份启动Rails服务器不会触发工作程序集群

时间:2018-12-30 21:00:01

标签: ruby-on-rails ruby-on-rails-5 puma

我想以生产模式启动Rails服务器,作为运行辅助集群的守护进程。当我启动Rails程序时,一切都会按预期进行。

rails s -e production -b 0.0.0.0
=> Booting Puma
=> Rails 5.0.0.1 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
[12340] Puma starting in cluster mode...
[12340] * Version 3.4.0 (ruby 2.3.0-p0), codename: Owl Bowl Brawl
[12340] * Min threads: 5, max threads: 5
[12340] * Environment: production
[12340] * Process workers: 3
[12340] * Preloading application
[12340] * Listening on tcp://0.0.0.0:3000
[12340] Use Ctrl-C to stop
[12340] - Worker 0 (pid: 12347) booted, phase: 0
[12340] - Worker 1 (pid: 12349) booted, phase: 0
[12340] - Worker 2 (pid: 12353) booted, phase: 0

但是,当我添加-d rails以单模式启动时,通过检查正在运行的进程来确认

rails s -e production -b 0.0.0.0 -d
=> Booting Puma
=> Rails 5.0.0.1 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options

检查正在运行的进程会确认仅一个实例正在运行,而不是预期的集群模式。

那么,如何正确地与工人一起启动守护进程?

非常感谢您的帮助。

注意:如果有帮助,我也正在运行puma_worker_killer进行滚动重启。

导轨(5.0.0.1) 彪马(3.4.0) puma_worker_killer(0.1.0)

1 个答案:

答案 0 :(得分:1)

根据Puma文档,以bundle exec puma开头的是recommended

然后您可以start a cluster像这样:puma -t 8:32 -w 3。其中-t是线程的min:max,-w是工作线程的数量。