gpt4 book ai didi

ruby-on-rails - 无限启动循环中的 Systemd 和 Puma

转载 作者:行者123 更新时间:2023-12-04 18:29:58 25 4
gpt4 key购买 nike

我正在用 puma 和 systemd 把头撞在墙上。我使用工头来设置我的 systemd 文件,但无法让 puma 退出其重启循环。 Ubuntu 16。

Jun 19 02:48:12 ip-172-31-28-225 systemd[1]: Stopped rajlogviewer-web.service.
Jun 19 02:48:12 ip-172-31-28-225 systemd[1]: Started rajlogviewer-web.service.
Jun 19 02:48:12 ip-172-31-28-225 rajlogviewer-web.service[8954]: APP_DIR = /home/ubuntu/rajlogviewer, SHARED_DIR /home/ubuntu/rajlogviewer/shared
Jun 19 02:48:12 ip-172-31-28-225 rajlogviewer-web.service[8954]: [8954] Puma starting in cluster mode...
Jun 19 02:48:12 ip-172-31-28-225 rajlogviewer-web.service[8954]: [8954] * Version 3.6.0 (ruby 2.3.3-p222), codename: Sleepy Sunday Serenity
Jun 19 02:48:12 ip-172-31-28-225 rajlogviewer-web.service[8954]: [8954] * Min threads: 1, max threads: 6
Jun 19 02:48:12 ip-172-31-28-225 rajlogviewer-web.service[8954]: [8954] * Environment: production
Jun 19 02:48:12 ip-172-31-28-225 rajlogviewer-web.service[8954]: [8954] * Process workers: 2
Jun 19 02:48:12 ip-172-31-28-225 rajlogviewer-web.service[8954]: [8954] * Preloading application
Jun 19 02:48:14 ip-172-31-28-225 rajlogviewer-web.service[8954]: [8954] * Listening on tcp://0.0.0.0:3000
Jun 19 02:48:14 ip-172-31-28-225 rajlogviewer-web.service[8954]: [8954] * Listening on unix:///home/ubuntu/rajlogviewer/shared/tmp/sockets/puma.sock
Jun 19 02:48:14 ip-172-31-28-225 rajlogviewer-web.service[8954]: [8954] * Daemonizing...
Jun 19 02:48:24 ip-172-31-28-225 systemd[1]: rajlogviewer-web.service: Service hold-off time over, scheduling restart.
Jun 19 02:48:24 ip-172-31-28-225 systemd[1]: Stopped rajlogviewer-web.service.
Jun 19 02:48:24 ip-172-31-28-225 systemd[1]: Started rajlogviewer-web.service.

它只是无限期地重新启动。这是我的 systemd 初始化文件
/etc/systemd/system/rajlogviewer-web.service
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/rajlogviewer/current
#Environment=PATH=/home/ubuntu/.rvm/gems/ruby-2.3.3@rajlogsViewer/bin:$PATH
WorkingDirectory=/home/ubuntu/rajlogviewer/current/
ExecStart=/bin/bash -lc 'PATH=/home/ubuntu/.rvm/gems/ruby-2.3.3@rajlogsViewer/bin:$PATH exec /home/ubuntu/.rvm/bin/rvm ruby-2.3.3 do bundle exec puma -C /home/ubuntu/rajlogviewer
/shared/config/puma.rb --daemon'
Restart=no
RestartSec=10
StandardInput=null
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n
KillMode=mixed
TimeoutStopSec=5

当使用“cap production puma:start”启动时,应用程序通常会在 5 秒内启动,因此 RestartSec=10 应该可以工作。让它20秒没有区别。

puma.stderr.log 和 puma.stdout.log 没有什么有趣的。

有任何想法吗?

最佳答案

您应该删除 --daemon systemd 的选项,有几种类型的单元:

Configures the unit process startup type that affects the functionality of ExecStart and related options. One of:

simpleThe default value. The process started with ExecStart is the main process of the service.

forking – The process started with ExecStart spawns a child process that becomes the main process of the service. The parent process exits when the startup is complete.

oneshot – This type is similar to simple, but the process exits before starting consequent units. dbus – This type is similar to simple, but consequent units are started only after the main process gains a D-Bus name.

notify – This type is similar to simple, but consequent units are started only after a notification message is sent via the sd_notify() function.

idle – similar to simple, the actual execution of the service binary is delayed until all jobs are finished, which avoids mixing the status output with shell output of services.



默认值为 简单 ,为了 puma 配置,您使用 --daemon与 systemd 配置相矛盾的选项。

关于ruby-on-rails - 无限启动循环中的 Systemd 和 Puma,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44621638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com