File: 2012_fix_test_avoid_rerunning_janus.patch

package info (click to toggle)
janus 1.1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,744 kB
  • sloc: ansic: 87,791; javascript: 16,056; makefile: 696; sh: 282; python: 257; lisp: 9
file content (48 lines) | stat: -rw-r--r-- 1,302 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Description: Start Janus only if it is not aleady running
Author: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Bug-Debian: https://bugs.debian.org/1102692
Forwarded: https://github.com/meetecho/janus-gateway/pull/3551
Last-Update: 2025-06-05

[gjover@sipwise.com:
 - Fallback to "echo 0" instead of "true".
 - Quote variables. ]
---

--- janus-1.1.2.orig/test/test_aiortc.sh
+++ janus-1.1.2/test/test_aiortc.sh
@@ -7,9 +7,14 @@ PATH="$JANUS_SRC/src:$PATH"
 TEST=${1-"$SCRIPTPATH/echo.py"}
 URL=${2-"ws://localhost:8188/"}
 
-echo "Starting Janus binary ..."
-janus >/dev/null 2>&1 &
-JANUS_PID=$!
+JANUS_RUNNING=$(pgrep -xc janus || echo 0)
+if [ "$JANUS_RUNNING" -gt 0 ]; then
+    echo "Not starting Janus, already running ..."
+else
+    echo "Starting Janus binary ..."
+    janus >/dev/null 2>&1 &
+    JANUS_PID=$!
+fi
 
 echo "Waiting for some seconds before launching the test ..."
 sleep 5
@@ -19,10 +24,14 @@ python3 $TEST $URL
 
 if [ $? -eq 0 ]; then
     echo "TEST SUCCEEDED"
-    kill -9 $JANUS_PID 2>/dev/null
+    if [ "$JANUS_RUNNING" -eq 0 ]; then
+        kill -9 "$JANUS_PID" 2>/dev/null
+    fi
     exit 0
 else
     echo "TEST FAILED"
-    kill -9 $JANUS_PID 2>/dev/null
+    if [ "$JANUS_RUNNING" -eq 0 ]; then
+        kill -9 "$JANUS_PID" 2>/dev/null
+    fi
     exit 1
 fi