diff --git a/modules/rhizo_base/files/bin/notify-freeswitch.sh b/modules/rhizo_base/files/bin/notify-freeswitch.sh new file mode 100644 index 0000000..968f9a8 --- /dev/null +++ b/modules/rhizo_base/files/bin/notify-freeswitch.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Puppet has made some change that requires a Freeswitch restart. +# Place flag file anyway as fallback. Service will delete it +if [ ! -f /tmp/FS-dirty ] ; then + echo 1 > /tmp/FS-dirty +fi + +if [ `/usr/bin/fs_cli -x 'fsctl shutdown_check'` == "true" ] ; then + exit +fi + +# Trigger an "elegant" shutdown - +# (Shutdown when there are no active calls, but don't disable service in the meantime) +# This won't return until FS actually shuts down. +exec /usr/bin/fs_cli -x 'fsctl shutdown elegant' & + diff --git a/modules/rhizo_base/files/freeswitch.service b/modules/rhizo_base/files/freeswitch.service index 458fea9..ba0764e 100644 --- a/modules/rhizo_base/files/freeswitch.service +++ b/modules/rhizo_base/files/freeswitch.service @@ -8,6 +8,7 @@ PIDFile=/run/freeswitch/freeswitch.pid Environment="DAEMON_OPTS=-nonat" EnvironmentFile=-/etc/default/freeswitch ExecStart=/usr/bin/freeswitch -u root -g freeswitch -ncwait $DAEMON_OPTS +ExecStopPost=/bin/sh -c "if [ -f /tmp/FS-dirty ]; then rm /tmp/FS-dirty; fi" TimeoutSec=45s Restart=always User=root diff --git a/modules/rhizo_base/manifests/init.pp b/modules/rhizo_base/manifests/init.pp index b88ea6c..3f6cd77 100644 --- a/modules/rhizo_base/manifests/init.pp +++ b/modules/rhizo_base/manifests/init.pp @@ -459,7 +459,7 @@ schedule { 'never': } exec { 'notify-freeswitch': - command => '/bin/echo 1 > /tmp/FS-dirty', + command => '/home/rhizomatica/bin/notify-freeswitch.sh', refreshonly => true, }