RHEL 7 systemctl:将多个服务合并为一个,独立启动服务

RHEL 7 systemctl:将多个服务合并为一个,独立启动服务

我已按照 RedHat 的步骤将多个服务启动为一个服务。 https://access.redhat.com/solutions/3097871

/etc/systemd/system/myapps.target

[Unit]
Description=App Service Unit

# This collection of apps should be started at boot time.
[Install]
WantedBy=multi-user.target

App1.服务

/etc/systemd/system/app1.service

[Unit]
Description= Instance of App1 Service
PartOf=myapps.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/mark/bin/app1.sh start
ExecStop=/home/mark/bin/app1.sh stop

# When the service runs globally, make it run as a particular user for added security
#User=user1
#Group=group1

# When systemctl enable is used, make this start when the App service starts
[Install]
WantedBy=myapps.target

App2.服务

  [Unit]
Description= Instance of App2 Service
PartOf=myapps.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/mark/bin/app2.sh start
ExecStop=/home/mark/bin/app2.sh stop

# When the service runs globally, make it run as a particular user for added security
#User=user1
#Group=group1

[Install]
WantedBy=myapps.target

我想独立停止 app1.service。但是当我检查 myapps.target 的状态时,我没有看到当前 app1.service 状态为已停止。相反,它显示 app1.service 正在运行。我该如何更改 myapps.target 以反映状态?

提前致谢。

相关内容