停止 CentOS 7 systemd 服务会停止多个目标

停止 CentOS 7 systemd 服务会停止多个目标

我正在尝试使用 systemctl 管理多个服务实例。我在 /etc/systemd/system 中有两个文件:

cat [email protected]

[Unit]
Description="FOO instance #%i"
PartOf=FOO.target
Wants=network-online.target
Requires=pacemaker.service
After=network.target network-online.target pacemaker.service
StartLimitIntervalSec=300
StartLimitBurst=5

[Service]
Type=forking
User=myuser
Group=mygrp
WorkingDirectory=/usr/local/bin
ExecStart=/usr/local/bin/StartFOO.sh -s %i -f no
ExecStop=/usr/local/bin/StopFOO.sh  -s %i
LimitNOFILE=16384
LimitNPROC=514340
LimitCORE=infinity
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

[Unit]
Description=FOO Workers
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

[Install]
WantedBy=multi-user.target

当服务器重新启动或通过运行 systemctl start 时,所有 16 个服务都会完美停止和启动[电子邮件受保护]系统控制停止[电子邮件受保护]但是,在我重新启动服务器后,如果我停止一项服务,它就会停止所有服务。如果我重新启动所有服务,它们都会正常启动和停止,一次一个。直到下一次服务器重新启动。

解决方案是将“PartOf”从 [Unit] 移动到 [Install] 部分[电子邮件受保护]

相关内容