You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

httpd进程监控Watchdog无法随其启停的systemd配置咨询

Fixing Systemd Configuration for Httpd Watchdog Service

Let's get your watchdog service properly synced with httpd's lifecycle. The issue with your current setup is that BindsTo only ensures the watchdog stops when httpd stops, but it doesn't trigger the watchdog to start when httpd is launched again. Here's the adjusted configuration and breakdown:

Updated [Unit] and [Install] Sections

[Unit]
# Ensures watchdog stops if httpd is terminated (normal or abnormal)
BindsTo=httpd.service
# Ensures watchdog is included in restart/stop operations targeting httpd
PartOf=httpd.service
# Starts watchdog only after httpd is fully up
After=httpd.service

[Service]
# Keep your existing service logic here (the watchdog functionality that restarts the device on httpd failure)
# Example placeholder:
# ExecStart=/path/to/your/watchdog-script.sh
# Restart=on-failure

[Install]
# Tells systemd to start this service whenever httpd starts
WantedBy=httpd.service

Key Changes Explained

  • PartOf=httpd.service: This fills the gap left by BindsTo—it ensures that when you run systemctl restart httpd, the watchdog is restarted alongside it, and crucially, when httpd is started (after being stopped), the watchdog will also start automatically.
  • WantedBy=httpd.service in [Install]: This links the watchdog service to httpd's activation chain. You'll need to run systemctl enable your-watchdog-service.service once to set this up permanently.

How to Apply the Fix

  1. Update your watchdog service file (usually located at /etc/systemd/system/your-watchdog-service.service) with the above sections.
  2. Reload systemd to pick up the changes:
    systemctl daemon-reload
    
  3. Enable the watchdog service to ensure it's tied to httpd's startup:
    systemctl enable your-watchdog-service.service
    

Now your watchdog will:

  • Start automatically whenever httpd starts
  • Stop when httpd stops
  • Restart when httpd is restarted
  • Continue performing its core function of restarting the device if httpd hangs or crashes

内容的提问来源于stack exchange,提问作者Pontus Thuvesson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:08:57