-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·55 lines (49 loc) · 1.16 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·55 lines (49 loc) · 1.16 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -euo pipefail
PID_FILE=".dev.smolvlm.pid"
NPM_SCRIPT="dev"
usage() {
echo "Usage: $0 {start|stop|status|restart}"
exit 1
}
start() {
if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
echo "Dev server already running (PID $(cat "$PID_FILE"))"
echo " http://localhost:5173"
return
fi
npm run "$NPM_SCRIPT" &
echo $! > "$PID_FILE"
echo "Dev server started (PID $!)"
echo " http://localhost:5173"
}
stop() {
if [[ ! -f "$PID_FILE" ]]; then
echo "Dev server not running"
return
fi
local pid
pid=$(cat "$PID_FILE")
if kill "$pid" 2>/dev/null; then
echo "Dev server stopped (PID $pid)"
else
echo "Process $pid not found — cleaning up stale PID file"
fi
rm "$PID_FILE"
}
status() {
if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
echo "Dev server running (PID $(cat "$PID_FILE"))"
echo " http://localhost:5173"
else
echo "Dev server not running"
[[ -f "$PID_FILE" ]] && rm "$PID_FILE"
fi
}
case "${1:-}" in
start) start ;;
stop) stop ;;
status) status ;;
restart) stop; start ;;
*) usage ;;
esac