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] 섹션으로 이동하는 것입니다.[이메일 보호됨]

관련 정보