gpt4 book ai didi

systemd - Puma systemd 重新启动超时并且似乎失败,尽管实际上已经成功

转载 作者:行者123 更新时间:2023-12-03 08:17:48 27 4
gpt4 key购买 nike

我们有一个 systemd 服务,根据建议的配置 here 来管理 Puma 进程。 .

虽然看起来运行良好,但重新启动超时,因此看起来失败,即使它们是成功的。如何调试这一类问题? systemd 期望它没有得到什么?

$ systemctl restart puma
Job for puma.service failed because a timeout was exceeded.
See "systemctl status puma.service" and "journalctl -xe" for details.

然而:

$ systemctl status puma.service
● puma.service - Puma HTTP Server
Loaded: loaded (/etc/systemd/system/puma.service; enabled; vendor preset: enabled)
Active: activating (start) since Tue 2021-08-17 16:21:54 UTC; 30s ago
TriggeredBy: ● puma.socket
Main PID: 1791114 (bundle)
Tasks: 40 (limit: 7028)
Memory: 561.9M
CGroup: /system.slice/puma.service
├─1791114 puma 4.3.8 (unix:///srv/app/shared/tmp/sockets/puma.sock) [20210817160414]
├─1791178 puma: cluster worker 0: 1791114 [20210817160414]
└─1791190 puma: cluster worker 1: 1791114 [20210817160414]

Aug 17 16:21:55 domain.tld bundle[1791114]: [1791114] * Environment: production
Aug 17 16:21:55 domain.tld bundle[1791114]: [1791114] * Process workers: 2
Aug 17 16:21:55 domain.tld bundle[1791114]: [1791114] * Preloading application
Aug 17 16:22:08 domain.tld bundle[1791114]: [1791114] * Activated unix:///srv/app/shared/tmp/sockets/puma.sock
Aug 17 16:22:08 domain.tld bundle[1791114]: [1791114] ! WARNING: Detected 2 Thread(s) started in app boot:
Aug 17 16:22:08 domain.tld bundle[1791114]: [1791114] ! #<Thread:0x0000585fceb5fcf8 /srv/nlr/app/shared/bundle/rub>
Aug 17 16:22:08 domain.tld bundle[1791114]: [1791114] ! #<Rack::MiniProfiler::FileStore::CacheCleanupThread:0x0000>
Aug 17 16:22:08 domain.tld bundle[1791114]: [1791114] Use Ctrl-C to stop
Aug 17 16:22:08 domain.tld bundle[1791114]: [1791114] - Worker 0 (pid: 1791178) booted, phase: 0
Aug 17 16:22:08 domain.tld bundle[1791114]: [1791114] - Worker 1 (pid: 1791190) booted, phase: 0

还有:

    $ journalctl -xe
-- Automatic restarting of the unit puma.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Aug 17 16:24:56 domain.tld audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=puma comm=>
Aug 17 16:24:56 domain.tld audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=puma comm=">
Aug 17 16:24:56 domain.tld systemd[1]: Stopped Puma HTTP Server.
-- Subject: A stop job for unit puma.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit puma.service has finished.
--
-- The job identifier is 142665 and the job result is done.
Aug 17 16:24:56 domain.tld systemd[1]: Starting Puma HTTP Server...
-- Subject: A start job for unit puma.service has begun execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit puma.service has begun execution.
--
-- The job identifier is 142665.
Aug 17 16:24:57 domain.tld bundle[1791690]: [1791690] Puma starting in cluster mode...
Aug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Version 4.3.8 (ruby 2.7.4-p191), codename: Mysterious Trav>
Aug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Min threads: 5, max threads: 16
Aug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Environment: production
Aug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Process workers: 2
Aug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Preloading application
Aug 17 16:25:07 domain.tld bundle[1791690]: [1791690] * Activated unix:///srv/app/shared/tmp/sockets/puma.sock
Aug 17 16:25:07 domain.tld bundle[1791690]: [1791690] ! WARNING: Detected 2 Thread(s) started in app boot:
Aug 17 16:25:07 domain.tld bundle[1791690]: [1791690] ! #<Thread:0x000062e706be2490 /srv/app/shared/bundle/rub>
Aug 17 16:25:07 domain.tld bundle[1791690]: [1791690] ! #<Rack::MiniProfiler::FileStore::CacheCleanupThread:0x0000>
Aug 17 16:25:07 domain.tld bundle[1791690]: [1791690] Use Ctrl-C to stop
Aug 17 16:25:07 domain.tld bundle[1791690]: [1791690] - Worker 0 (pid: 1791747) booted, phase: 0
Aug 17 16:25:07 domain.tld bundle[1791690]: [1791690] - Worker 1 (pid: 1791756) booted, phase: 0
[1]: https://puma.io/puma/file.systemd.html

puma.service:

[Unit]
Description=Puma HTTP Server
After=network.target

Requires=puma.socket

[Service]
Type=notify

WatchdogSec=10

User=app

WorkingDirectory=/srv/app/current

EnvironmentFile=/srv/app/current/.env

ExecStart=/srv/.rbenv/shims/bundle exec --keep-file-descriptors puma -C /srv/app/current/config/puma.rb

Restart=always

[Install]
WantedBy=multi-user.target

puma.socket:

[Unit]
Description=Puma HTTP Server Accept Sockets

[Socket]
SocketUser=app
SocketGroup=app
ListenStream=/srv/app/shared/tmp/sockets/puma.sock

NoDelay=true
ReusePort=true
Backlog=1024

[Install]
WantedBy=sockets.target

最佳答案

答案在于与sd_notify的集成:使用“简单”类型避免了这个问题。毫无疑问,它可以与 sd_notify 一起使用,但这需要额外的配置才能让应用程序与 systemd 通信状态。

所以代替:

Type=notify
WatchdogSec=10

用途:

Type=simple

...除非您也想弄清楚 sd_notify 集成。

关于systemd - Puma systemd 重新启动超时并且似乎失败,尽管实际上已经成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68821051/

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