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 <sebastian_ml@gmx.net>
This commit is contained in:
parent
72cb5b8350
commit
5a35a231ec
3 changed files with 20 additions and 69 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
19
net/freeswitch-stable/patches/370-procd-compat.patch
Normal file
19
net/freeswitch-stable/patches/370-procd-compat.patch
Normal file
|
@ -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) {
|
Loading…
Reference in a new issue