我们有一个 systemd 服务来管理 Puma 进程,基于此处建议的配置。
\n尽管它看起来运行良好,但重新启动超时,因此看起来失败,即使它们是成功的。如何调试这一类问题?systemd 期望它没有得到什么?
\n$ systemctl restart puma\nJob for puma.service failed because a timeout was exceeded.\nSee "systemctl status puma.service" and "journalctl -xe" for details.\nRun Code Online (Sandbox Code Playgroud)\n然而:
\n$ systemctl status puma.service\n\xe2\x97\x8f puma.service - Puma HTTP Server\n Loaded: loaded (/etc/systemd/system/puma.service; enabled; vendor preset: enabled)\n Active: activating (start) since Tue 2021-08-17 16:21:54 UTC; 30s ago\nTriggeredBy: \xe2\x97\x8f puma.socket\n Main PID: 1791114 (bundle)\n Tasks: 40 (limit: 7028)\n Memory: 561.9M\n CGroup: /system.slice/puma.service\n \xe2\x94\x9c\xe2\x94\x801791114 puma 4.3.8 (unix:///srv/app/shared/tmp/sockets/puma.sock) [20210817160414]\n \xe2\x94\x9c\xe2\x94\x801791178 puma: cluster worker 0: 1791114 [20210817160414]\n \xe2\x94\x94\xe2\x94\x801791190 puma: cluster worker 1: 1791114 [20210817160414]\n\nAug 17 16:21:55 domain.tld bundle[1791114]: [1791114] * Environment: production\nAug 17 16:21:55 domain.tld bundle[1791114]: [1791114] * Process workers: 2\nAug 17 16:21:55 domain.tld bundle[1791114]: [1791114] * Preloading application\nAug 17 16:22:08 domain.tld bundle[1791114]: [1791114] * Activated unix:///srv/app/shared/tmp/sockets/puma.sock\nAug 17 16:22:08 domain.tld bundle[1791114]: [1791114] ! WARNING: Detected 2 Thread(s) started in app boot:\nAug 17 16:22:08 domain.tld bundle[1791114]: [1791114] ! #<Thread:0x0000585fceb5fcf8 /srv/nlr/app/shared/bundle/rub>\nAug 17 16:22:08 domain.tld bundle[1791114]: [1791114] ! #<Rack::MiniProfiler::FileStore::CacheCleanupThread:0x0000>\nAug 17 16:22:08 domain.tld bundle[1791114]: [1791114] Use Ctrl-C to stop\nAug 17 16:22:08 domain.tld bundle[1791114]: [1791114] - Worker 0 (pid: 1791178) booted, phase: 0\nAug 17 16:22:08 domain.tld bundle[1791114]: [1791114] - Worker 1 (pid: 1791190) booted, phase: 0\nRun Code Online (Sandbox Code Playgroud)\n和:
\n $ journalctl -xe\n-- Automatic restarting of the unit puma.service has been scheduled, as the result for\n-- the configured Restart= setting for the unit.\nAug 17 16:24:56 domain.tld audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg=\'unit=puma comm=>\nAug 17 16:24:56 domain.tld audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg=\'unit=puma comm=">\nAug 17 16:24:56 domain.tld systemd[1]: Stopped Puma HTTP Server.\n-- Subject: A stop job for unit puma.service has finished\n-- Defined-By: systemd\n-- Support: http://www.ubuntu.com/support\n-- \n-- A stop job for unit puma.service has finished.\n-- \n-- The job identifier is 142665 and the job result is done.\nAug 17 16:24:56 domain.tld systemd[1]: Starting Puma HTTP Server...\n-- Subject: A start job for unit puma.service has begun execution\n-- Defined-By: systemd\n-- Support: http://www.ubuntu.com/support\n-- \n-- A start job for unit puma.service has begun execution.\n-- \n-- The job identifier is 142665.\nAug 17 16:24:57 domain.tld bundle[1791690]: [1791690] Puma starting in cluster mode...\nAug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Version 4.3.8 (ruby 2.7.4-p191), codename: Mysterious Trav>\nAug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Min threads: 5, max threads: 16\nAug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Environment: production\nAug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Process workers: 2\nAug 17 16:24:57 domain.tld bundle[1791690]: [1791690] * Preloading application\nAug 17 16:25:07 domain.tld bundle[1791690]: [1791690] * Activated unix:///srv/app/shared/tmp/sockets/puma.sock\nAug 17 16:25:07 domain.tld bundle[1791690]: [1791690] ! WARNING: Detected 2 Thread(s) started in app boot:\nAug 17 16:25:07 domain.tld bundle[1791690]: [1791690] ! #<Thread:0x000062e706be2490 /srv/app/shared/bundle/rub>\nAug 17 16:25:07 domain.tld bundle[1791690]: [1791690] ! #<Rack::MiniProfiler::FileStore::CacheCleanupThread:0x0000>\nAug 17 16:25:07 domain.tld bundle[1791690]: [1791690] Use Ctrl-C to stop\nAug 17 16:25:07 domain.tld bundle[1791690]: [1791690] - Worker 0 (pid: 1791747) booted, phase: 0\nAug 17 16:25:07 domain.tld bundle[1791690]: [1791690] - Worker 1 (pid: 1791756) booted, phase: 0\n [1]: https://puma.io/puma/file.systemd.html\nRun Code Online (Sandbox Code Playgroud)\n美洲狮服务:
\n[Unit]\nDescription=Puma HTTP Server\nAfter=network.target\n\nRequires=puma.socket\n\n[Service]\nType=notify\n\nWatchdogSec=10\n\nUser=app\n\nWorkingDirectory=/srv/app/current\n\nEnvironmentFile=/srv/app/current/.env\n\nExecStart=/srv/.rbenv/shims/bundle exec --keep-file-descriptors puma -C /srv/app/current/config/puma.rb\n\nRestart=always\n\n[Install]\nWantedBy=multi-user.target\nRun Code Online (Sandbox Code Playgroud)\n美洲狮插座:
\n[Unit]\nDescription=Puma HTTP Server Accept Sockets\n\n[Socket]\nSocketUser=app\nSocketGroup=app\nListenStream=/srv/app/shared/tmp/sockets/puma.sock\n\nNoDelay=true\nReusePort=true\nBacklog=1024\n\n[Install]\nWantedBy=sockets.target\nRun Code Online (Sandbox Code Playgroud)\n
答案在于与 的集成sd_notify:使用“简单”类型来避免这个问题。毫无疑问,它可以与 一起使用sd_notify,但这需要额外的配置才能让应用程序与systemd.
所以而不是:
Type=notify
WatchdogSec=10
Run Code Online (Sandbox Code Playgroud)
使用:
Type=simple
Run Code Online (Sandbox Code Playgroud)
...除非您也想弄清楚sd_notify集成。
| 归档时间: |
|
| 查看次数: |
1179 次 |
| 最近记录: |