小编gri*_*evg的帖子

让 systemctl 优雅地关闭进程

我为 manqge HLTV 服务器制作了一个小型 systemctl 服务(它记录游戏中的演示并将其存储在磁盘上):

[Unit]
Description=HLTV server
Requires=cs16.service
After=cs16.service

[Service]
Type=simple
User=cs16
Group=cs16
UMask=007

ExecStart=/home/cs16/server/hltv_start.sh

Restart=on-failure

# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=300

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

它工作得很好,但是如果我关闭/重新启动系统服务,它会杀死该进程,从而损坏当前正在编写的演示。

为了正确保存演示,我需要在 htlv 命令工具中输入“quit”或“stop”。有没有办法让 systemctl 在关闭程序之前将其中一个命令发送到程序?

systemd services

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

services ×1

systemd ×1