Add start and stop launcher scripts
This commit is contained in:
21
start.sh
Executable file
21
start.sh
Executable 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")"
|
||||
Reference in New Issue
Block a user