我有一个 systemd 服务(用于 heka),这让我有些头疼。
问题是即使 heka 守护进程在启动后不久死亡,“start”也会成功返回。如果配置文件有误,就会发生这种情况,例如:进程将启动,它将验证配置,如果对所发现的内容不满意,则会终止。在这种情况下,Systemd 成功返回。
有没有办法强制systemd在初始化后检查程序状态?也许在进程开始后睡眠 n 秒?
这是脚本:
[Unit]
Description=Heka event/metric/log collection and routing daemon
After=network.target auditd.service
ConditionPathExists=!/etc/heka/hekad_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/heka
Type=simple
PIDFile=/var/run/hekad.pid
ExecStart=/usr/bin/hekad -config=/etc/heka
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
StandardError=inherit
[Install]
WantedBy=multi-user.target
Alias=heka.service
Run Code Online (Sandbox Code Playgroud) systemd ×1