-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-sonar.command
More file actions
executable file
·39 lines (35 loc) · 1.04 KB
/
Copy pathstart-sonar.command
File metadata and controls
executable file
·39 lines (35 loc) · 1.04 KB
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
#!/bin/zsh
cd "$(dirname "$0")"
URL="http://localhost:4173/index.html"
LOG_FILE="/tmp/sonar-server.log"
PORT_PID="$(lsof -ti tcp:4173 -sTCP:LISTEN | head -1)"
FORCE_RESTART="${1:-}"
if [ -n "$PORT_PID" ]; then
if [ "$FORCE_RESTART" = "--restart" ]; then
echo "Restarting SONAR on port 4173."
kill "$PORT_PID" >/dev/null 2>&1
sleep 1
elif curl -fsS --max-time 1 "$URL" >/dev/null 2>&1; then
echo "SONAR is already available at $URL"
open "$URL"
exit 0
fi
if [ -n "$(lsof -ti tcp:4173 -sTCP:LISTEN | head -1)" ]; then
echo "Could not stop the existing SONAR server automatically."
echo "Please run this in Terminal, then start SONAR again:"
echo "lsof -ti tcp:4173 | xargs kill"
exit 1
fi
fi
echo "Starting SONAR at $URL"
nohup python3 sonar_server.py > "$LOG_FILE" 2>&1 &
sleep 1
if curl -fsS --max-time 2 "$URL" >/dev/null 2>&1; then
open "$URL"
echo "SONAR is running at $URL"
echo "Server log: $LOG_FILE"
else
echo "SONAR did not respond on port 4173."
echo "Server log: $LOG_FILE"
exit 1
fi