每日 apt 升级和清理活动后,特定的 systemctl 服务停止

每日 apt 升级和清理活动后,特定的 systemctl 服务停止

我在多台服务器上遇到问题(发生了两次,每月一次),Daily apt upgrade and clean activities由于某种原因,启动时我的特定服务停止了,然后再也没有启动它,因此它被关闭,然后我需要手动启动它。

在系统日志中我看到这个:

Mar  7 06:59:24 server systemd[1]: Starting Daily apt upgrade and clean activities...
Mar  7 06:59:38 server systemd[1]: Reloading.
Mar  7 06:59:38 server systemd[1]: Started ACPI event daemon.
Mar  7 06:59:38 server systemd[1]: Stopping Odoo 11...
Mar  7 06:59:39 server systemd[1]: Stopped Odoo 11.
Mar  7 06:59:39 server systemd[1]: Stopped PostgreSQL RDBMS.
Mar  7 06:59:39 server systemd[1]: Stopping PostgreSQL Cluster 9.5-main...
Mar  7 06:59:41 server systemd[1]: Stopped PostgreSQL Cluster 9.5-main.
Mar  7 06:59:42 server systemd[1]: Reloading.
Mar  7 06:59:42 server systemd[1]: Starting Daily apt download activities...
Mar  7 06:59:42 server systemd[1]: Started ACPI event daemon.
Mar  7 06:59:42 server systemd[1]: Reloading.
Mar  7 06:59:42 server systemd[1]: Started ACPI event daemon.
Mar  7 06:59:42 server systemd[1]: Starting PostgreSQL Cluster 9.5-main...
Mar  7 06:59:45 server systemd[1]: Started PostgreSQL Cluster 9.5-main.
Mar  7 06:59:45 server systemd[1]: Starting PostgreSQL RDBMS...
Mar  7 06:59:45 server systemd[1]: Started PostgreSQL RDBMS.
Mar  7 06:59:51 server systemd[1]: Started Daily apt upgrade and clean activities.
Mar  7 06:59:59 server systemd[1]: Started Daily apt download activities.

从日志中可以看出,当它启动时,它还会启动 ACPI 事件守护进程,然后停止Odoo 11服务,但该服务保持停止状态,即使它不应该停止。

以下是 Odoo 11 服务的 systemd 配置:

[Unit]
Description=Odoo 11
Requires=postgresql.service
After=postgresql.service

[Service]
Type=simple
PermissionsStartOnly=true
User=odoo
Group=odoo
SyslogIdentifier=odoo11
ExecStart=/opt/odoo/venv/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo11.conf

[Install]
WantedBy=multi-user.target

systemd start-stop 服务配置可能出了问题?但如果我自己运行该服务,它就会按预期运行。

答案1

您可能希望Wants=与您的 PostgreSQL 服务依赖项一起使用,而不是Requires=

有了Wants=,您的应用程序就不会因为 PostgreSQL 因软件升级而停止/启动而停止。

欲了解更多区别,请参阅man systemd.unit

相关内容