-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·39 lines (30 loc) · 905 Bytes
/
start.sh
File metadata and controls
executable file
·39 lines (30 loc) · 905 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
PROJECT_DIR="$(pwd)"
LOG_DIR="$PROJECT_DIR/logs"
OUT_LOG="$LOG_DIR/runewager.log"
ERR_LOG="$LOG_DIR/runewager-error.log"
mkdir -p "$LOG_DIR"
touch "$OUT_LOG" "$ERR_LOG"
echo "Starting Runewager manually..."
echo "Working directory: $PROJECT_DIR"
NODE_MAJOR=$(node -v | sed 's/v\([0-9]*\).*/\1/')
if [[ "$NODE_MAJOR" -lt 20 ]]; then
echo "ERROR: Node.js 20+ required"
exit 1
fi
if [[ ! -f "$PROJECT_DIR/.env" ]]; then
echo "ERROR: .env missing"
exit 1
fi
PORT=$(grep -E '^PORT=' "$PROJECT_DIR/.env" | cut -d= -f2 | tr -d '"'\'' ' || echo "3000")
. "$PROJECT_DIR/scripts/helpers/free_port.sh"
free_port "$PORT" "runewager.service"
OLD_PID=$(pgrep -f "node.*${PROJECT_DIR}/index\.js" | head -1 || true)
if [[ -n "$OLD_PID" ]]; then
kill "$OLD_PID" 2>/dev/null || true
sleep 1
fi
node index.js >>"$OUT_LOG" 2>>"$ERR_LOG"
exit $?