-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
53 lines (43 loc) · 1.27 KB
/
Copy pathstart.sh
File metadata and controls
53 lines (43 loc) · 1.27 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
#!/usr/bin/env bash
# Launch FetPost on Linux / macOS.
set -e
cd "$(dirname "$0")"
ROOT="$(pwd)"
if [ ! -f .env ]; then
echo ".env not found. Run ./setup.sh first."
exit 1
fi
# Stop any prior instance still holding the ports
kill_port() {
local port=$1
local pids
pids=$(lsof -ti :$port 2>/dev/null || true)
if [ -n "$pids" ]; then
echo " stopping prior process on :$port (pid $pids)"
kill -9 $pids 2>/dev/null || true
fi
}
kill_port 3747
kill_port 4000
sleep 1
mkdir -p "$ROOT/.logs"
echo "Starting FetLife service..."
( cd "$ROOT/fetlife-poster" && nohup node --env-file="$ROOT/.env" src/server.js >"$ROOT/.logs/fetlife-poster.log" 2>&1 ) &
echo $! > "$ROOT/.logs/fetlife-poster.pid"
# Give the FetLife service a moment to bind its port before the UI tries to reach it.
sleep 4
echo "Starting UI..."
( cd "$ROOT/nexuspost-ui" && nohup node --env-file="$ROOT/.env" src/server.js >"$ROOT/.logs/ui.log" 2>&1 ) &
echo $! > "$ROOT/.logs/ui.pid"
sleep 3
URL="http://127.0.0.1:4000"
echo
echo "FetPost is running at $URL"
echo "Logs: $ROOT/.logs/{fetlife-poster,ui}.log"
echo "Run ./stop.sh to shut down."
echo
# Open browser if we can
case "$(uname)" in
Darwin) open "$URL" ;;
Linux) command -v xdg-open >/dev/null && xdg-open "$URL" >/dev/null 2>&1 || true ;;
esac