几周后 systemd oneshot 转为非活动状态(死亡)

几周后 systemd oneshot 转为非活动状态(死亡)

我启用了三个 systemd 配置:

  1. 我实际想要运行的服务(一个 dotnet 进程):
# systemd.conf
[Unit]
Description=MyService
After=network.target
StartLimitIntervalSec=0

[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple

User=deployer

# The path to the application root
WorkingDirectory=/srv/myapp/current/bin

ExecStart=/bin/bash -c "dotnet MyService.dll"

Restart=always
RestartSec=5s

Environment="ThreadPool_ForceMinWorkerThreads=200"
Environment="COMPlus_ThreadPool_ForceMinWorkerThreads=200"
Environment="COMPlus_ThreadPool_ForceMaxWorkerThreads=10000"

[Install]
WantedBy=multi-user.target
  1. 用于监视正在触摸的文件的重启程序和重启程序路径(这将触发上述服务重新启动):
# systemd-restarter.conf
[Unit]
Description=MyService restart
After=network.target

[Service]
Type=oneshot

ExecStart=/bin/bash -c "pkill -f 'dotnet MyService.dll'"

[Install]
WantedBy=multi-user.target
# systemd-restarter-path.conf
[Path]
PathModified=/srv/myapp/shared/restart.txt

[Install]
WantedBy=multi-user.target

几周后,systemd-restarter-path.conf 和 systemd-restarter.conf 突然进入死亡(非活动)状态,我不知道为什么。

我们使用 capistrano 进行部署,因此它会触及 restart.txt 文件,然后 systemd 会重新启动该进程。

systemctl 命令示例:

# systemctl status restart-service.service
● restart-service.service - restart
   Loaded: loaded (/etc/systemd/system/restart-service.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sat 2020-10-10 00:41:11 UTC; 20h ago
 Main PID: 3037 (code=exited, status=0/SUCCESS)
# systemctl status restart.path
● restart.path
   Loaded: loaded (/etc/systemd/system/restart.path; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sat 2020-10-10 00:43:30 UTC; 20h ago

如果我在 restart.path 和 restart-service.service 上运行 systemctl restart ,它会再次开始工作。或者如果我只是重新启动服务器。

知道为什么它停止监视 restart.txt 文件吗?

相关内容