我有一个由大约 15 个服务组成的系统。它们没有相互依赖性(即没有服务需要另一个服务来启动),并且它们在启动完成时通知 systemd(即Type=notify)。
问题是,如果我同时启动它们,我的系统就会过载,并且进程会由于 systemd 超时而被终止。
我想要做的是将我的服务“分组”,以便它们一个接一个地启动,没有特定的顺序。这可以通过 systemd 服务文件实现吗?
顺便说一句:这是我的服务文件的模板:
[Unit]
Description=Template service file
After=network.target
[Service]
Type=notify
User=1000
Group=1000
# Set the working directory and the binary to start
WorkingDirectory=/home/user/
ExecStart=/path/to/some/process
# The standard input and output are useless (i.e. unused by the process)
StandardInput=null
StandardOutput=null
# Disable the standard error because all logs are already saved in a specific directory
StandardError=null
# Send SIGTERM then SIGKILL after TimeoutStopSec seconds (default: 2)
KillMode=mixed
TimeoutStopSec=2
# Setup a …Run Code Online (Sandbox Code Playgroud)