r/vmhost: Retry vm-autostart if libvirt is down
If the _libvirt_ daemon has not fully started by the time `vm-autostart` runs, we want it to fail and try again shortly. To allow this, we first attempt to connect to the _libvirt_ socket, and if that fails, stop immediately and try again in a second. This way, the first few VMs don't get skipped with the assumption that they're missing, just because the daemon wasn't ready yet.unifi-restore
parent
4df047cf76
commit
2ee86f6344
|
@ -4,6 +4,8 @@ After=libvirt.service
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
RequiresMountsFor=/var/lib/libvirt/images
|
RequiresMountsFor=/var/lib/libvirt/images
|
||||||
|
StartLimitInterval=1s
|
||||||
|
StartLimitBurst=1
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
@ -11,6 +13,7 @@ RemainAfterExit=yes
|
||||||
Environment=LIBVIRT_DEFAULT_URI=qemu:///system
|
Environment=LIBVIRT_DEFAULT_URI=qemu:///system
|
||||||
ExecStart=/usr/local/libexec/vm-autostart.sh
|
ExecStart=/usr/local/libexec/vm-autostart.sh
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
RestartSec=1
|
||||||
|
|
||||||
CapabilityBoundingSet=
|
CapabilityBoundingSet=
|
||||||
DeviceAllow=
|
DeviceAllow=
|
||||||
|
|
|
@ -5,6 +5,8 @@ if [ ! -r /etc/vm-autostart ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
virsh connect || exit
|
||||||
|
|
||||||
while read name args; do
|
while read name args; do
|
||||||
if [ "${name}" = delay ]; then
|
if [ "${name}" = delay ]; then
|
||||||
sleep ${args}
|
sleep ${args}
|
||||||
|
|
Loading…
Reference in New Issue