0

我目前正在开发一个 Symfony 4 应用程序,它使用Symfony Messenger与专门的工作人员一起处理一些后台作业。

我使用具有以下配置的 systemd v241 运行工作程序:

[Unit]
Description=Symfony Worker
StartLimitIntervalSec=0
StartLimitBurst=0

[Service]
WorkingDirectory=/symfony-app/current
ExecStart=/bin/bash -lc 'bin/console messenger:consume async --memory-limit=512M --time-limit=3600'
ExecStop=/bin/bash -lc 'bin/console messenger:stop-workers'
StandardOutput=syslog
StandardError=syslog
Restart=always
PrivateTmp=true
NoNewPrivileges=true
RestartSec=5s

[Install]
WantedBy=default.target

正如文档中所写,worker 不能永远运行,因此它每小时或每次达到 512M 的内存限制时都会重新启动。

我的问题是它并不总是重新启动。有时会,但有时不会,我唯一得到的就是Main process exited, code=killed, status=15/TERM日志中的 a 。

知道为什么以及如何解决这个问题吗?

4

1 回答 1

1

负责启动服务的用户未启用逗留。启用它解决了我的问题。

于 2021-01-25T08:54:39.430 回答