From 7c6132f7ddc89fb2a5ae5a85891ec82926c20e84 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 23 May 2019 22:38:45 -0400 Subject: [PATCH] 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 --- debian/pvc-daemon.install | 4 +++- debian/pvc-daemon.postinst | 17 ++++++++++++----- debian/pvc-daemon.prerm | 4 +++- node-daemon/pvc-flush.service | 15 +++++++++++++++ node-daemon/pvcd.service | 3 ++- node-daemon/pvcd.target | 7 +++++++ 6 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 node-daemon/pvc-flush.service create mode 100644 node-daemon/pvcd.target diff --git a/debian/pvc-daemon.install b/debian/pvc-daemon.install index e7183947..6895f6a5 100644 --- a/debian/pvc-daemon.install +++ b/debian/pvc-daemon.install @@ -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 diff --git a/debian/pvc-daemon.postinst b/debian/pvc-daemon.postinst index 9ae80517..895a66e8 100644 --- a/debian/pvc-daemon.postinst +++ b/debian/pvc-daemon.postinst @@ -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 diff --git a/debian/pvc-daemon.prerm b/debian/pvc-daemon.prerm index 09aaa5c3..a6e8c6ab 100644 --- a/debian/pvc-daemon.prerm +++ b/debian/pvc-daemon.prerm @@ -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 diff --git a/node-daemon/pvc-flush.service b/node-daemon/pvc-flush.service new file mode 100644 index 00000000..814f7306 --- /dev/null +++ b/node-daemon/pvc-flush.service @@ -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 diff --git a/node-daemon/pvcd.service b/node-daemon/pvcd.service index 74dfa8d2..fd2ec8b8 100644 --- a/node-daemon/pvcd.service +++ b/node-daemon/pvcd.service @@ -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 diff --git a/node-daemon/pvcd.target b/node-daemon/pvcd.target new file mode 100644 index 00000000..96f8adb6 --- /dev/null +++ b/node-daemon/pvcd.target @@ -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