From 5a35a231ec86ee6e71d18fba0e6ced4f323f4cda Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Mon, 12 Nov 2018 21:20:55 +0100 Subject: [PATCH] freeswitch-stable: procd compatibility procd runs as pid 1. When freeswitch realizes that its parent has pid 1, it thinks that it has been orphaned and terminates the console thread. That's why procd isn't able to get freeswitch's console output. This commit mutes the check in src/switch_console.c. Now console output is properly logged. The workaround parameters "-nc -nf" are replaced by a proper "-c" ("console"). Additionally this commit hands control over killing freeswitch to procd. It's no longer done by the script. This simplifies things quite a bit. Signed-off-by: Sebastian Kemper --- .../files/freeswitch.hotplug | 7 --- net/freeswitch-stable/files/freeswitch.init | 63 +------------------ .../patches/370-procd-compat.patch | 19 ++++++ 3 files changed, 20 insertions(+), 69 deletions(-) create mode 100644 net/freeswitch-stable/patches/370-procd-compat.patch diff --git a/net/freeswitch-stable/files/freeswitch.hotplug b/net/freeswitch-stable/files/freeswitch.hotplug index 10778cb..0914dca 100644 --- a/net/freeswitch-stable/files/freeswitch.hotplug +++ b/net/freeswitch-stable/files/freeswitch.hotplug @@ -21,13 +21,6 @@ pgrep $FS &> /dev/null if [ $? -eq 0 ]; then $LOG_NOTICE stopping $FS /etc/init.d/$FS stop &> /dev/null - pgrep $FS &> /dev/null - if [ $? -eq 0 ]; then - $LOG_ERR failed to stop $FS - exit 1 - else - $LOG_NOTICE $FS stopped - fi fi config_get FS_HOTPLUG_TIMEOUT hotplug timeout diff --git a/net/freeswitch-stable/files/freeswitch.init b/net/freeswitch-stable/files/freeswitch.init index eb064d4..ac76fa3 100644 --- a/net/freeswitch-stable/files/freeswitch.init +++ b/net/freeswitch-stable/files/freeswitch.init @@ -87,70 +87,9 @@ start_service() { -temp "$fs_dir_temp" \ -u "$fs_user" \ $OPTIONS \ - -nc \ - -nf + -c # forward stderr to logd procd_set_param stderr 1 procd_close_instance } -stop_service() { - local retval - local mypid - local TIMEOUT=30 - local timeout=$TIMEOUT - - pgrep $FS &> /dev/null - [ $? -ne 0 ] && exit 0 - - [ -f "$fs_dir_run"/${FS}.pid ] - retval=$? - - # init script could find itself in a scenario where FS was started - # very recently, so make it wait a while for a pid file to appear - while [ $retval -ne 0 -a $timeout -gt 0 ]; do - sleep 1 - [ -f "$fs_dir_run"/${FS}.pid ] - retval=$? - timeout=$(($timeout-1)) - done - - [ $retval -eq 0 ] || { - $LOGGER PID file does not exist - exit 1 - } - - mypid=$(cat "$fs_dir_run"/${FS}.pid) - - [ "$mypid" -gt 1 ] 2> /dev/null || { - $LOGGER PID file contains garbage - exit 1 - } - - timeout=$TIMEOUT - kill $mypid 2>/dev/null - pgrep $FS | grep -w $mypid &>/dev/null - retval=$? - - while [ $retval -eq 0 -a $timeout -gt 0 ]; do - sleep 10 - pgrep $FS | grep -w $mypid &>/dev/null - retval=$? - [ $retval -eq 0 ] && kill $mypid 2>/dev/null - timeout=$(($timeout-10)) - done - - [ $retval -ne 1 ] && { - $LOGGER application seems to hang - $LOGGER sending SIGKILL - kill -SIGKILL $mypid 2>/dev/null - sleep 3 - pgrep $FS | grep -w $mypid &>/dev/null - retval=$? - } - - [ $retval -ne 1 ] && { - $LOGGER failed to stop $FS - exit 1 - } -} diff --git a/net/freeswitch-stable/patches/370-procd-compat.patch b/net/freeswitch-stable/patches/370-procd-compat.patch new file mode 100644 index 0000000..0549a03 --- /dev/null +++ b/net/freeswitch-stable/patches/370-procd-compat.patch @@ -0,0 +1,19 @@ +--- a/src/switch_console.c ++++ b/src/switch_console.c +@@ -1053,10 +1053,12 @@ static void *SWITCH_THREAD_FUNC console_ + while (running) { + int32_t arg = 0; + +- if (getppid() == 1) { +- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We've become an orphan, no more console for us.\n"); +- break; +- } ++ // Parent PID is 1 when started by procd - so FS is not an orphan. ++ // Plus we still want the output. ++ //if (getppid() == 1) { ++ // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We've become an orphan, no more console for us.\n"); ++ // break; ++ //} + + switch_core_session_ctl(SCSC_CHECK_RUNNING, &arg); + if (!arg) { -- 2.30.2