2

I'm trying to manager qemu with systemd. If qemu crashes, it can be restart automatically. I have the following unit file:

[Unit]
Description=vm manager
After=network.target
Before=shutdown.target reboot.target poweroff.target halt.target

[Service]
Type=forking
ExecStart=/root/vm/vm-manager.sh start-vm
ExecStop=/root/vm/vm-manager.sh stop-vm
KillSignal=SIGCONT
PIDFile=/root/vm/run/pid
WatchdogSec=30s
Restart=on-failure

[Install]
WantedBy=multi-user.target

I didn't call sd_notify(0, "WATCHDOG=1") in my application, but the service didn't move to 'failed' state after 30 seconds. I have two questions:

  1. In my opinion, this service should be restarted after 30 seconds, why it keeps running until I kill or stop it?
  2. When I kill qemu manually(I take qemu process as the main process), the service restart immediately, without waiting.

Besides the two questions, if there's anything wrong or suggestion about the unit file, please raise it freely.

Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.