snapshot of https://github.com/jitsi/jibri.git @ 3b45602c539ec69d128ea152ae587d0b6582191a (2026-09-15)
This commit is contained in:
45
resources/debian-package/etc/jitsi/jibri/asoundrc
Normal file
45
resources/debian-package/etc/jitsi/jibri/asoundrc
Normal file
@@ -0,0 +1,45 @@
|
||||
pcm.amix {
|
||||
type dmix
|
||||
ipc_key 219345
|
||||
slave.pcm "hw:Loopback,0,0"
|
||||
}
|
||||
|
||||
pcm.asnoop {
|
||||
type dsnoop
|
||||
ipc_key 219346
|
||||
slave.pcm "hw:Loopback_1,1,0"
|
||||
}
|
||||
|
||||
pcm.aduplex {
|
||||
type asym
|
||||
playback.pcm "amix"
|
||||
capture.pcm "asnoop"
|
||||
}
|
||||
|
||||
pcm.bmix {
|
||||
type dmix
|
||||
ipc_key 219347
|
||||
slave.pcm "hw:Loopback_1,0,0"
|
||||
}
|
||||
|
||||
pcm.bsnoop {
|
||||
type dsnoop
|
||||
ipc_key 219348
|
||||
slave.pcm "hw:Loopback,1,0"
|
||||
}
|
||||
|
||||
pcm.bduplex {
|
||||
type asym
|
||||
playback.pcm "bmix"
|
||||
capture.pcm "bsnoop"
|
||||
}
|
||||
|
||||
pcm.pjsua {
|
||||
type plug
|
||||
slave.pcm "bduplex"
|
||||
}
|
||||
|
||||
pcm.!default {
|
||||
type plug
|
||||
slave.pcm "aduplex"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
ShowTaskBar = 0
|
||||
2
resources/debian-package/etc/jitsi/jibri/jibri.conf
Normal file
2
resources/debian-package/etc/jitsi/jibri/jibri.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
jibri {
|
||||
}
|
||||
31
resources/debian-package/etc/jitsi/jibri/pjsua.config
Normal file
31
resources/debian-package/etc/jitsi/jibri/pjsua.config
Normal file
@@ -0,0 +1,31 @@
|
||||
--capture-dev=11
|
||||
--playback-dev=14
|
||||
--video
|
||||
--vcapture-dev=1
|
||||
--no-color
|
||||
--log-level=5
|
||||
--app-log-level=5
|
||||
--auto-update-nat 0
|
||||
--disable-stun
|
||||
--no-tcp
|
||||
--dis-codec GSM
|
||||
--dis-codec H263
|
||||
--dis-codec iLBC
|
||||
--dis-codec G722
|
||||
--dis-codec speex
|
||||
--dis-codec pcmu
|
||||
--dis-codec pcma
|
||||
--dis-codec opus
|
||||
--add-codec pcmu
|
||||
--add-codec pcma
|
||||
--add-codec speex
|
||||
--add-codec G722
|
||||
--add-codec opus
|
||||
--no-vad
|
||||
--ec-tail 0
|
||||
--quality 10
|
||||
--max-calls=1
|
||||
--auto-keyframe=30
|
||||
--no-stderr
|
||||
--log-file=/var/log/jitsi/jibri/pjsua.log
|
||||
--id "jibri <sip:jibri@127.0.0.1>"
|
||||
119
resources/debian-package/etc/jitsi/jibri/xorg-video-dummy.conf
Normal file
119
resources/debian-package/etc/jitsi/jibri/xorg-video-dummy.conf
Normal file
@@ -0,0 +1,119 @@
|
||||
# This xorg configuration file is meant to be used by xpra
|
||||
# to start a dummy X11 server.
|
||||
# For details, please see:
|
||||
# https://xpra.org/Xdummy.html
|
||||
|
||||
Section "ServerFlags"
|
||||
Option "DontVTSwitch" "true"
|
||||
Option "AllowMouseOpenFail" "true"
|
||||
Option "PciForceNone" "true"
|
||||
Option "AutoEnableDevices" "false"
|
||||
Option "AutoAddDevices" "false"
|
||||
EndSection
|
||||
|
||||
Section "Device"
|
||||
Identifier "dummy_videocard"
|
||||
Driver "dummy"
|
||||
Option "ConstantDPI" "true"
|
||||
#VideoRam 4096000
|
||||
#VideoRam 256000
|
||||
VideoRam 192000
|
||||
EndSection
|
||||
|
||||
Section "Monitor"
|
||||
Identifier "dummy_monitor"
|
||||
HorizSync 5.0 - 1000.0
|
||||
VertRefresh 5.0 - 200.0
|
||||
#This can be used to get a specific DPI, but only for the default resolution:
|
||||
#DisplaySize 508 317
|
||||
#NOTE: the highest modes will not work without increasing the VideoRam
|
||||
# for the dummy video card.
|
||||
Modeline "32768x32768" 15226.50 32768 35800 39488 46208 32768 32771 32781 32953
|
||||
Modeline "32768x16384" 7516.25 32768 35544 39192 45616 16384 16387 16397 16478
|
||||
Modeline "16384x8192" 2101.93 16384 16416 24400 24432 8192 8390 8403 8602
|
||||
Modeline "8192x4096" 424.46 8192 8224 9832 9864 4096 4195 4202 4301
|
||||
Modeline "5496x1200" 199.13 5496 5528 6280 6312 1200 1228 1233 1261
|
||||
Modeline "5280x1080" 169.96 5280 5312 5952 5984 1080 1105 1110 1135
|
||||
Modeline "5280x1200" 191.40 5280 5312 6032 6064 1200 1228 1233 1261
|
||||
Modeline "5120x3200" 199.75 5120 5152 5904 5936 3200 3277 3283 3361
|
||||
Modeline "4800x1200" 64.42 4800 4832 5072 5104 1200 1229 1231 1261
|
||||
Modeline "3840x2880" 133.43 3840 3872 4376 4408 2880 2950 2955 3025
|
||||
Modeline "3840x2560" 116.93 3840 3872 4312 4344 2560 2622 2627 2689
|
||||
Modeline "3840x2048" 91.45 3840 3872 4216 4248 2048 2097 2101 2151
|
||||
Modeline "3840x1080" 100.38 3840 3848 4216 4592 1080 1081 1084 1093
|
||||
Modeline "3600x1200" 106.06 3600 3632 3984 4368 1200 1201 1204 1214
|
||||
Modeline "3288x1080" 39.76 3288 3320 3464 3496 1080 1106 1108 1135
|
||||
Modeline "2048x2048" 49.47 2048 2080 2264 2296 2048 2097 2101 2151
|
||||
Modeline "2048x1536" 80.06 2048 2104 2312 2576 1536 1537 1540 1554
|
||||
Modeline "2560x1600" 47.12 2560 2592 2768 2800 1600 1639 1642 1681
|
||||
Modeline "2560x1440" 42.12 2560 2592 2752 2784 1440 1475 1478 1513
|
||||
Modeline "1920x1440" 69.47 1920 1960 2152 2384 1440 1441 1444 1457
|
||||
Modeline "1920x1200" 26.28 1920 1952 2048 2080 1200 1229 1231 1261
|
||||
Modeline "1920x1080" 23.53 1920 1952 2040 2072 1080 1106 1108 1135
|
||||
Modeline "1680x1050" 20.08 1680 1712 1784 1816 1050 1075 1077 1103
|
||||
Modeline "1600x1200" 22.04 1600 1632 1712 1744 1200 1229 1231 1261
|
||||
Modeline "1600x900" 33.92 1600 1632 1760 1792 900 921 924 946
|
||||
Modeline "1440x900" 30.66 1440 1472 1584 1616 900 921 924 946
|
||||
ModeLine "1366x768" 72.00 1366 1414 1446 1494 768 771 777 803
|
||||
Modeline "1280x1024" 31.50 1280 1312 1424 1456 1024 1048 1052 1076
|
||||
Modeline "1280x800" 24.15 1280 1312 1400 1432 800 819 822 841
|
||||
Modeline "1280x768" 23.11 1280 1312 1392 1424 768 786 789 807
|
||||
Modeline "1360x768" 24.49 1360 1392 1480 1512 768 786 789 807
|
||||
Modeline "1024x768" 18.71 1024 1056 1120 1152 768 786 789 807
|
||||
Modeline "768x1024" 19.50 768 800 872 904 1024 1048 1052 1076
|
||||
|
||||
|
||||
#common resolutions for android devices (both orientations):
|
||||
Modeline "800x1280" 25.89 800 832 928 960 1280 1310 1315 1345
|
||||
Modeline "1280x800" 24.15 1280 1312 1400 1432 800 819 822 841
|
||||
Modeline "720x1280" 30.22 720 752 864 896 1280 1309 1315 1345
|
||||
Modeline "1280x720" 27.41 1280 1312 1416 1448 720 737 740 757
|
||||
Modeline "768x1024" 24.93 768 800 888 920 1024 1047 1052 1076
|
||||
Modeline "1024x768" 23.77 1024 1056 1144 1176 768 785 789 807
|
||||
Modeline "600x1024" 19.90 600 632 704 736 1024 1047 1052 1076
|
||||
Modeline "1024x600" 18.26 1024 1056 1120 1152 600 614 617 631
|
||||
Modeline "536x960" 16.74 536 568 624 656 960 982 986 1009
|
||||
Modeline "960x536" 15.23 960 992 1048 1080 536 548 551 563
|
||||
Modeline "600x800" 15.17 600 632 688 720 800 818 822 841
|
||||
Modeline "800x600" 14.50 800 832 880 912 600 614 617 631
|
||||
Modeline "480x854" 13.34 480 512 560 592 854 873 877 897
|
||||
Modeline "848x480" 12.09 848 880 920 952 480 491 493 505
|
||||
Modeline "480x800" 12.43 480 512 552 584 800 818 822 841
|
||||
Modeline "800x480" 11.46 800 832 872 904 480 491 493 505
|
||||
#resolutions for android devices (both orientations)
|
||||
#minus the status bar
|
||||
#38px status bar (and width rounded up)
|
||||
Modeline "800x1242" 25.03 800 832 920 952 1242 1271 1275 1305
|
||||
Modeline "1280x762" 22.93 1280 1312 1392 1424 762 780 783 801
|
||||
Modeline "720x1242" 29.20 720 752 856 888 1242 1271 1276 1305
|
||||
Modeline "1280x682" 25.85 1280 1312 1408 1440 682 698 701 717
|
||||
Modeline "768x986" 23.90 768 800 888 920 986 1009 1013 1036
|
||||
Modeline "1024x730" 22.50 1024 1056 1136 1168 730 747 750 767
|
||||
Modeline "600x986" 19.07 600 632 704 736 986 1009 1013 1036
|
||||
Modeline "1024x562" 17.03 1024 1056 1120 1152 562 575 578 591
|
||||
Modeline "536x922" 16.01 536 568 624 656 922 943 947 969
|
||||
Modeline "960x498" 14.09 960 992 1040 1072 498 509 511 523
|
||||
Modeline "600x762" 14.39 600 632 680 712 762 779 783 801
|
||||
Modeline "800x562" 13.52 800 832 880 912 562 575 578 591
|
||||
Modeline "480x810" 12.59 480 512 552 584 810 828 832 851
|
||||
Modeline "848x442" 11.09 848 880 920 952 442 452 454 465
|
||||
Modeline "480x762" 11.79 480 512 552 584 762 779 783 801
|
||||
EndSection
|
||||
|
||||
Section "Screen"
|
||||
Identifier "dummy_screen"
|
||||
Device "dummy_videocard"
|
||||
Monitor "dummy_monitor"
|
||||
DefaultDepth 24
|
||||
SubSection "Display"
|
||||
Viewport 0 0
|
||||
Depth 24
|
||||
#Modes "1280x720"
|
||||
Modes "1920x1080"
|
||||
EndSubSection
|
||||
EndSection
|
||||
|
||||
Section "ServerLayout"
|
||||
Identifier "dummy_layout"
|
||||
Screen "dummy_screen"
|
||||
EndSection
|
||||
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Jibri Window Manager
|
||||
Requires=jibri-xorg.service
|
||||
After=jibri-xorg.service
|
||||
|
||||
[Service]
|
||||
User=jibri
|
||||
Group=jibri
|
||||
Environment=DISPLAY=:0
|
||||
ExecStart=/usr/bin/icewm-session
|
||||
Restart=on-failure
|
||||
RestartPreventExitStatus=255
|
||||
Type=simple
|
||||
|
||||
[Install]
|
||||
WantedBy=jibri.service
|
||||
@@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Jibri Xorg Process
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=jibri
|
||||
Group=jibri
|
||||
Environment=DISPLAY=:0
|
||||
ExecStart=/usr/bin/Xorg -nocursor -noreset +extension RANDR +extension RENDER -logfile /var/log/jitsi/jibri/xorg.log -config /etc/jitsi/jibri/xorg-video-dummy.conf :0
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
RestartPreventExitStatus=255
|
||||
Type=simple
|
||||
|
||||
[Install]
|
||||
WantedBy=jibri.service jibri-icewm.service
|
||||
19
resources/debian-package/etc/systemd/system/jibri.service
Normal file
19
resources/debian-package/etc/systemd/system/jibri.service
Normal file
@@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=Jibri Process
|
||||
Requires=jibri-icewm.service jibri-xorg.service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=jibri
|
||||
Group=jibri
|
||||
PermissionsStartOnly=true
|
||||
ExecStartPre=sudo -u jibri /usr/bin/google-chrome --timeout=1000 --headless about:blank
|
||||
ExecStart=/opt/jitsi/jibri/launch.sh
|
||||
ExecStop=/opt/jitsi/jibri/graceful_shutdown.sh
|
||||
ExecReload=/opt/jitsi/jibri/reload.sh
|
||||
Restart=always
|
||||
RestartPreventExitStatus=255
|
||||
Type=simple
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
39
resources/debian-package/opt/jitsi/jibri/collect-dump-logs.sh
Executable file
39
resources/debian-package/opt/jitsi/jibri/collect-dump-logs.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
# script that creates an archive in current folder
|
||||
# containing the heap and thread dump and the current log file
|
||||
|
||||
JAVA_HEAPDUMP_PATH="/tmp/java_*.hprof"
|
||||
STAMP=`date +%Y-%m-%d-%H%M`
|
||||
jibri_USER="jibri"
|
||||
jibri_UID=`id -u $jibri_USER`
|
||||
RUNNING=""
|
||||
unset PID
|
||||
|
||||
#Find any crashes in /var/crash from our user in the past 20 minutes, if they exist
|
||||
CRASH_FILES=$(find /var/crash -name '*.crash' -uid $jibri_UID -mmin -20 -type f)
|
||||
PID=$(systemctl show -p MainPID jibri 2>/dev/null | cut -d= -f2)
|
||||
|
||||
if [ ! -z $PID ]; then
|
||||
ps -p $PID | grep -q java
|
||||
[ $? -eq 0 ] && RUNNING="true"
|
||||
fi
|
||||
if [ ! -z $RUNNING ]; then
|
||||
echo "jibri pid $PID"
|
||||
THREADS_FILE="/tmp/stack-${STAMP}-${PID}.threads"
|
||||
HEAP_FILE="/tmp/heap-${STAMP}-${PID}.bin"
|
||||
sudo -u $jibri_USER jstack ${PID} > ${THREADS_FILE}
|
||||
sudo -u $jibri_USER jmap -dump:live,format=b,file=${HEAP_FILE} ${PID}
|
||||
tar zcvf jibri-dumps-${STAMP}-${PID}.tgz ${THREADS_FILE} ${HEAP_FILE} ${CRASH_FILES} /var/log/jitsi/jibri/* /tmp/hs_err_*
|
||||
rm ${HEAP_FILE} ${THREADS_FILE}
|
||||
else
|
||||
ls $JAVA_HEAPDUMP_PATH >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "jibri not running, but previous heap dump found."
|
||||
tar zcvf jibri-dumps-${STAMP}-crash.tgz $JAVA_HEAPDUMP_PATH ${CRASH_FILES} /var/log/jitsi/jibri/* /tmp/hs_err_*
|
||||
rm ${JAVA_HEAPDUMP_PATH}
|
||||
else
|
||||
echo "jibri not running, no previous dump found. Including logs only."
|
||||
tar zcvf jibri-dumps-${STAMP}-crash.tgz ${CRASH_FILES} /var/log/jitsi/jibri/* /tmp/hs_err_*
|
||||
fi
|
||||
fi
|
||||
10
resources/debian-package/opt/jitsi/jibri/finalize_sip.sh
Executable file
10
resources/debian-package/opt/jitsi/jibri/finalize_sip.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
LOG_DIR_PATH="/var/log/jitsi/jibri"
|
||||
LATEST_PJSUA_LOG_FILE="$LOG_DIR_PATH/pjsua.log"
|
||||
AGGREGATED_PJSUA_LOG_FILE="$LOG_DIR_PATH/pjsua_all.log"
|
||||
|
||||
if [ -f "$LATEST_PJSUA_LOG_FILE" ]; then
|
||||
echo "Appending pjsua logs from $LATEST_PJSUA_LOG_FILE, to $AGGREGATED_PJSUA_LOG_FILE"
|
||||
cat "$LATEST_PJSUA_LOG_FILE" >> "$AGGREGATED_PJSUA_LOG_FILE"
|
||||
fi
|
||||
8
resources/debian-package/opt/jitsi/jibri/graceful_shutdown.sh
Executable file
8
resources/debian-package/opt/jitsi/jibri/graceful_shutdown.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONF="/etc/jitsi/jibri/jibri.conf"
|
||||
|
||||
PORT=$(hocon -f $CONF get jibri.api.http.internal-api-port 2>/dev/null || true)
|
||||
[[ -z "$PORT" ]] && PORT=3333
|
||||
|
||||
curl -sX POST http://127.0.0.1:$PORT/jibri/api/internal/v1.0/gracefulShutdown
|
||||
3
resources/debian-package/opt/jitsi/jibri/launch.sh
Executable file
3
resources/debian-package/opt/jitsi/jibri/launch.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec java -Djava.util.logging.config.file=/etc/jitsi/jibri/logging.properties -Dconfig.file="/etc/jitsi/jibri/jibri.conf" -jar /opt/jitsi/jibri/jibri.jar --config "/etc/jitsi/jibri/config.json"
|
||||
3
resources/debian-package/opt/jitsi/jibri/pjsua.sh
Executable file
3
resources/debian-package/opt/jitsi/jibri/pjsua.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec /usr/local/bin/pjsua --config-file /etc/jitsi/jibri/pjsua.config "$@" > /dev/null
|
||||
8
resources/debian-package/opt/jitsi/jibri/reload.sh
Executable file
8
resources/debian-package/opt/jitsi/jibri/reload.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONF="/etc/jitsi/jibri/jibri.conf"
|
||||
|
||||
PORT=$(hocon -f $CONF get jibri.api.http.internal-api-port 2>/dev/null || true)
|
||||
[[ -z "$PORT" ]] && PORT=3333
|
||||
|
||||
curl -sX POST http://127.0.0.1:$PORT/jibri/api/internal/v1.0/notifyConfigChanged
|
||||
8
resources/debian-package/opt/jitsi/jibri/shutdown.sh
Executable file
8
resources/debian-package/opt/jitsi/jibri/shutdown.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONF="/etc/jitsi/jibri/jibri.conf"
|
||||
|
||||
PORT=$(hocon -f $CONF get jibri.api.http.internal-api-port 2>/dev/null || true)
|
||||
[[ -z "$PORT" ]] && PORT=3333
|
||||
|
||||
curl -sX POST http://127.0.0.1:$PORT/jibri/api/internal/v1.0/shutdown
|
||||
154
resources/debian-package/opt/jitsi/jibri/wait_graceful_shutdown.sh
Executable file
154
resources/debian-package/opt/jitsi/jibri/wait_graceful_shutdown.sh
Executable file
@@ -0,0 +1,154 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# 1. The script issues shutdown command via the graceful shutdown command
|
||||
# If unsuccessful then it exits with 1.
|
||||
# 2. If the code is ok then it checks if jibri has exited.
|
||||
# 3. If not then it polls jibri statistics until recording status is not true
|
||||
# 4. Gives some time for jibri to shutdown. If it does not quit after that
|
||||
# time then it kills the process. If the process was successfully killed 0 is
|
||||
# returned and 1 otherwise.
|
||||
#
|
||||
# NOTE: script depends on the tool jq, used to parse json, and curl to access URLs
|
||||
#
|
||||
|
||||
# Initialize arguments
|
||||
CURL_BIN="/usr/bin/curl"
|
||||
|
||||
# URL for jibri status
|
||||
STATUS_URL="http://localhost:2222/jibri/api/v1.0/health"
|
||||
# URL to POST to signal jibri stop/cleanup
|
||||
STOP_URL="http://localhost:2222/jibri/api/v1.0/stopService"
|
||||
|
||||
# wait this long before failing stop curl command
|
||||
STOP_TIMEOUT=3600
|
||||
# wait this long before failing status curl command
|
||||
STATUS_TIMEOUT=30
|
||||
|
||||
# sleep this long between checking jibri status
|
||||
SLEEP_TIME=10
|
||||
# delay shutdown AT MOST 6 hours = 21600 seconds
|
||||
TERMINATION_DELAY_TIMEOUT=21600
|
||||
|
||||
function getJibriStatus() {
|
||||
$CURL_BIN --max-time $STATUS_TIMEOUT $STATUS_URL 2>/dev/null
|
||||
}
|
||||
|
||||
function stopJibri() {
|
||||
$CURL_BIN -H 'Content-Type: application/json' -d '{}' --max-time $STOP_TIMEOUT $STOP_URL 2>/dev/null
|
||||
}
|
||||
|
||||
function isRecording() {
|
||||
STATUS=`getJibriStatus`
|
||||
echo $STATUS | jq -r ".status.busyStatus"
|
||||
}
|
||||
|
||||
verbose=1
|
||||
|
||||
# Parse arguments
|
||||
OPTIND=1
|
||||
while getopts "h:t:s" opt; do
|
||||
case "$opt" in
|
||||
h)
|
||||
STATUS_URL=$OPTARG
|
||||
;;
|
||||
t)
|
||||
STATUS_TIMEOUT=$OPTARG
|
||||
;;
|
||||
s)
|
||||
verbose=0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
|
||||
# Prints info messages
|
||||
function printInfo {
|
||||
if [ "$verbose" == "1" ]
|
||||
then
|
||||
echo "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Prints errors
|
||||
function printError {
|
||||
echo "$@" 1>&2
|
||||
}
|
||||
|
||||
function gracefulShutdownJibri() {
|
||||
/opt/jitsi/jibri/graceful_shutdown.sh
|
||||
}
|
||||
|
||||
pid=$(/bin/systemctl show -p MainPID jibri 2>/dev/null | cut -d= -f2)
|
||||
|
||||
echo -n "Graceful shutdown signal..."
|
||||
gracefulShutdownJibri
|
||||
shutdownStatus=$?
|
||||
echo "sent"
|
||||
if [ $shutdownStatus == 0 ];
|
||||
then
|
||||
printInfo "Graceful shutdown started"
|
||||
recordingStatus=`isRecording`
|
||||
SLEEP_COUNT=0
|
||||
while [[ $recordingStatus == "BUSY" ]]; do
|
||||
if [[ $SLEEP_COUNT -ge $TERMINATION_DELAY_TIMEOUT ]]; then
|
||||
printInfo "WAITED $TERMINATION_DELAY_TIMEOUT seconds, stopping jibri."
|
||||
# send signal to stop streaming/recording and upload any recordings pending
|
||||
stopJibri
|
||||
# mark jibri service as intentionally stopped to avoid restarts
|
||||
/usr/sbin/service jibri stop
|
||||
# stop looping
|
||||
break;
|
||||
fi
|
||||
printInfo "A recording is in progress"
|
||||
sleep $SLEEP_TIME
|
||||
SLEEP_COUNT=$(( $SLEEP_COUNT + $SLEEP_TIME ))
|
||||
recordingStatus=`isRecording`
|
||||
done
|
||||
|
||||
sleep 5
|
||||
|
||||
# mark jibri service as intentionally stopped to avoid restarts
|
||||
/usr/sbin/service jibri stop
|
||||
|
||||
if ps -p $pid > /dev/null 2>&1
|
||||
then
|
||||
printInfo "It is still running, lets give it $STATUS_TIMEOUT seconds"
|
||||
sleep $STATUS_TIMEOUT
|
||||
if ps -p $pid > /dev/null 2>&1
|
||||
then
|
||||
printError "Jibri did not exit after $STATUS_TIMEOUT sec - killing $pid"
|
||||
kill $pid
|
||||
else
|
||||
printInfo "Jibri shutdown OK"
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
printInfo "Jibri shutdown OK"
|
||||
exit 0
|
||||
fi
|
||||
# check for 3 seconds if we managed to kill
|
||||
for I in 1 2 3
|
||||
do
|
||||
if ps -p $pid > /dev/null 2>&1
|
||||
then
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
if ps -p $pid > /dev/null 2>&1
|
||||
then
|
||||
printError "Failed to kill $pid"
|
||||
printError "Sending force kill to $pid"
|
||||
kill -9 $pid
|
||||
if ps -p $pid > /dev/null 2>&1
|
||||
then
|
||||
printError "Failed to force kill $pid"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
printInfo "Jibri shutdown OK"
|
||||
exit 0
|
||||
else
|
||||
printError "Failed to signal shutdown of Jibri: $shutdownStatus"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user