Browse Source

added proper shutdown handlers

Grega Bremec 2 years ago
parent
commit
daea6e3fb1
2 changed files with 14 additions and 0 deletions
  1. 7 0
      images/entrypoint-psacct.sh
  2. 7 0
      images/entrypoint-sysstat.sh

+ 7 - 0
images/entrypoint-psacct.sh

@@ -12,6 +12,13 @@ if [ -z "$(capsh --decode=$(cat /proc/self/status | grep ^CapEff | cut -f2) | gr
     exit 1
     exit 1
 fi
 fi
 
 
+# Shutdown handler.
+trap_shutdown() {
+    echo "Shutting down..."
+    exit 0
+}
+trap trap_shutdown SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM
+
 # Announce collection period.
 # Announce collection period.
 PERIOD=10
 PERIOD=10
 if [ -n "$1" ]; then
 if [ -n "$1" ]; then

+ 7 - 0
images/entrypoint-sysstat.sh

@@ -6,6 +6,13 @@ if [ ${UID} -ne 0 ]; then
     exit 1
     exit 1
 fi
 fi
 
 
+# Shutdown handler.
+trap_shutdown() {
+    echo "Shutting down..."
+    exit 0
+}
+trap trap_shutdown SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM
+
 # Announce collection period.
 # Announce collection period.
 PERIOD=10
 PERIOD=10
 if [ -n "$1" ]; then
 if [ -n "$1" ]; then