Add start and stop launcher scripts

This commit is contained in:
sas.fajri
2026-04-13 19:32:42 +07:00
parent 0ed36b98af
commit 3ef5d72d4d
3 changed files with 66 additions and 0 deletions

21
start.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PID_FILE="$ROOT_DIR/.doclink-web.pid"
LOG_FILE="$ROOT_DIR/doclink-web.log"
PORT="${PORT:-5198}"
if [[ -f "$PID_FILE" ]]; then
OLD_PID="$(cat "$PID_FILE" 2>/dev/null || true)"
if [[ -n "${OLD_PID:-}" ]] && kill -0 "$OLD_PID" 2>/dev/null; then
echo "DocLink Web is already running on pid $OLD_PID"
exit 0
fi
rm -f "$PID_FILE"
fi
nohup env PORT="$PORT" node "$ROOT_DIR/server.js" >"$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "DocLink Web started on http://localhost:$PORT"
echo "PID: $(cat "$PID_FILE")"