diff --git a/config.json b/config.json index 135cbe5..7ca7dbf 100644 --- a/config.json +++ b/config.json @@ -2,11 +2,13 @@ "DIRS": { "SDL_HOME": "~/.sdl", "SDL_CONF": "SDL_HOME/conf", + "SDL_DOCS": "SDL_HOME/docs", "SDL_LOGS": "SDL_HOME/logs", "SDL_DIST": "SDL_HOME/dist", "SDL_DATA": "SDL_HOME/data", "SDL_PROJ": "SDL_DATA/proj", "SDL_JOBS": "SDL_DATA/jobs", + "SDL_SCRIPTS": "SDL_HOME/scripts", "SDL_MGR": "SDL_HOME/sdl-mgr", "SDL_WKR": "SDL_HOME/sdl-wkr", "SDL_NODEJS": "SDL_HOME/nodejs" diff --git a/install-sdl.sh b/install-sdl.sh index 6aadcff..7326130 100755 --- a/install-sdl.sh +++ b/install-sdl.sh @@ -384,6 +384,15 @@ cd "$SDL_MGR/current/app" export PATH="$SDL_NODEJS/current/bin:$PATH" $NPM_BIN install + +# ------------------------------------------------------------ +# Copy Start / Stop Scripts +# ------------------------------------------------------------ +cp "$SDL_MGR/current/scripts/start-sdl-mgr.sh" "$SDL_HOME/scripts/" +cp "$SDL_MGR/current/scripts/stop-sdl-mgr.sh" "$SDL_HOME/scripts/" +cp "$SDL_MGR/current/scripts/status-sdl-mgr.sh" "$SDL_HOME/scripts/" + + # ------------------------------------------------------------ # Install Systemd Unit Files # Copy SDL_MGR/current/scripts/sdl-mgr.service to ~/.config/systemd/user @@ -394,6 +403,14 @@ echo "Installing SystemD Unit Files" mkdir -p ~/.config/systemd/user cp "$SDL_MGR/current/scripts/sdl-mgr.service" ~/.config/systemd/user/ + + + +# ------------------------------------------------------------ +# Start SDL Manager +# ------------------------------------------------------------ +systemctl --user stop sdl-mgr --no-pager +sleep 2 systemctl --user daemon-reload --no-pager systemctl --user restart sdl-mgr --no-pager sleep 3 @@ -412,4 +429,5 @@ echo "" echo "Removal Commands:" echo " WARNING: Backup data directory first!!!!" echo " systemctl --user disable sdl-mgr" -echo " rm -rf $SDL_HOME" \ No newline at end of file +echo " rm -rf $SDL_HOME" + diff --git a/sdl-mgr/scripts/start-sdl-mgr.sh b/sdl-mgr/scripts/start-sdl-mgr.sh index 6a076c3..78cda59 100755 --- a/sdl-mgr/scripts/start-sdl-mgr.sh +++ b/sdl-mgr/scripts/start-sdl-mgr.sh @@ -48,5 +48,5 @@ echo " Node: ${NODE_BIN}" export PATH="${NODE_BIN_DIR}:${PATH}" cd "${SDL_MGR_APP_DIR}" -# Start in foreground (use nohup or systemd for background) -exec "${NPM_BIN}" start \ No newline at end of file +# Start in foreground +"${NPM_BIN}" start & diff --git a/sdl-mgr/scripts/status-sdl-mgr.sh b/sdl-mgr/scripts/status-sdl-mgr.sh new file mode 100755 index 0000000..c41a68e --- /dev/null +++ b/sdl-mgr/scripts/status-sdl-mgr.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# status-sdl-mgr.sh - Script to show status of SDL Manager +set -euo pipefail + +# Get sdl-mgr PID +SDL_MGR_PID="" +for pid in $(pgrep -f 'node' 2>/dev/null || true); do + cwd=$(readlink /proc/$pid/cwd 2>/dev/null || true) + if [[ "$cwd" == *"sdl-mgr"* ]]; then + SDL_MGR_PID="$pid" + break + fi +done + +if [[ -z "$SDL_MGR_PID" ]]; then + echo "SDL Manager is not running" + exit 0 +fi + +echo "SDL Manager is running with PID: ${SDL_MGR_PID}" +exit 0 \ No newline at end of file diff --git a/sdl-wkr/scripts/status-sdl-wkr.sh b/sdl-wkr/scripts/status-sdl-wkr.sh new file mode 100755 index 0000000..c41a68e --- /dev/null +++ b/sdl-wkr/scripts/status-sdl-wkr.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# status-sdl-mgr.sh - Script to show status of SDL Manager +set -euo pipefail + +# Get sdl-mgr PID +SDL_MGR_PID="" +for pid in $(pgrep -f 'node' 2>/dev/null || true); do + cwd=$(readlink /proc/$pid/cwd 2>/dev/null || true) + if [[ "$cwd" == *"sdl-mgr"* ]]; then + SDL_MGR_PID="$pid" + break + fi +done + +if [[ -z "$SDL_MGR_PID" ]]; then + echo "SDL Manager is not running" + exit 0 +fi + +echo "SDL Manager is running with PID: ${SDL_MGR_PID}" +exit 0 \ No newline at end of file