Add node autoflush service and target

Add a systemd service to manage node flush/unflush, useful during
system startup and shutdown to avoid requiring administrator
intervention for this to occur. This is optional and the service is
not enabled by default, and the postinst script informs the
administrator of this.

Also adds a systemd target to collect the two service units together
and provide an easy way to flush+shutdown or startup+unflush the
entire PVC system.

Closes #28
This commit is contained in:
Joshua Boniface 2019-05-23 22:38:45 -04:00
parent 69462d2c7b
commit 7c6132f7dd
6 changed files with 42 additions and 8 deletions

View File

@ -1,4 +1,6 @@
node-daemon/pvcd.py usr/share/pvc
node-daemon/pvcd.service lib/systemd/system
node-daemon/pvcd.sample.yaml etc/pvc
node-daemon/pvcd usr/share/pvc
node-daemon/pvcd.target lib/systemd/system
node-daemon/pvcd.service lib/systemd/system
node-daemon/pvc-flush.service lib/systemd/system

View File

@ -1,10 +1,17 @@
#!/bin/sh
# Enable the service
# Enable the service and target
systemctl enable /lib/systemd/system/pvcd.service
systemctl enable /lib/systemd/system/pvcd.target
if systemctl is-active --quiet pvcd.service; then
echo "The PVC node daemon has not been restarted; this is up to the administrator."
else
echo "The PVC node daemon has not been started; create a config file at /etc/pvc/pvcd.conf then start it."
# Inform administrator of the autoflush daemon if it is not enabled
if ! systemctl is-active --quiet pvc-flush.service; then
echo "The PVC autoflush daemon (pvc-flush.service) is not enabled by default; enable it to perform automatic flush/unflush actions on host shutdown/startup."
fi
# Inform administrator of the service restart/startup not occurring automatically
if systemctl is-active --quiet pvcd.service; then
echo "The PVC node daemon (pvcd.service) has not been restarted; this is up to the administrator."
else
echo "The PVC node daemon (pvcd.service) has not been started; create a config file at /etc/pvc/pvcd.yaml then start it."
fi

View File

@ -1,4 +1,6 @@
#!/bin/sh
# Disable the service
# Disable the services
systemctl disable pvc-flush.service
systemctl disable pvcd.service
systemctl disable pvcd.target

View File

@ -0,0 +1,15 @@
# Parallel Virtual Cluster autoflush daemon
[Unit]
Description = Parallel Virtual Cluster autoflush daemon
After = pvcd.service
[Service]
Type = oneshot
WorkingDirectory = /usr/share/pvc
ExecStart = /usr/bin/pvc node unflush
ExecStop = /usr/bin/pvc node flush
Restart = never
[Install]
WantedBy = pvcd.target

View File

@ -1,4 +1,5 @@
# Parallel Virtual Cluster node daemon unit file
[Unit]
Description = Parallel Virtual Cluster node daemon
After = network-online.target libvirtd.service zookeeper.service
@ -12,4 +13,4 @@ ExecStart = /usr/share/pvc/pvcd.py
Restart = on-failure
[Install]
WantedBy = multi-user.target
WantedBy = pvcd.target

7
node-daemon/pvcd.target Normal file
View File

@ -0,0 +1,7 @@
# Parallel Virtual Cluster startup target
[Unit]
Description = Parallel Virtual Cluster target for managing all services collectively
[Install]
WantedBy = multi-user.target