重新启动时执行 ExecStopPost

重新启动时执行 ExecStopPost

如何正确配置服务,以便在操作系统重新启动时执行 ExecStopPost 中的命令。

my.service

[Unit]
Description=my.service
After=syslog.target
After=network.target
After=my-service.mount
ConditionFileNotEmpty=/opt/myService/myService.java
 
[Service]
User=UserName
Group=UserGroup
WorkingDirectory=/opt/myService
OOMScoreAdjust=-100
Type=forking
ExecStart=/usr/bin/java ./myService.java start
TimeoutStartSec=90
ExecStopPost=/usr/bin/java ./myService.java stop
TimeoutStopSec=30
 
Restart=on-failure
RestartSec=60
 
[Install]
WantedBy=multi-user.target

相关内容