Skip to content

Commit

Permalink
Stop start handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lwindolf committed Nov 18, 2023
1 parent c3b4bc3 commit f826245
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"main": "server.js",
"description": "WurmTerm, a friendly wurm walking along your SSH sessions. Backend service.",
"license": "GPL-3.0",
"version": "0.9.0",
"repository": {
"type": "git",
"url": "https://github.com/lwindolf/wurmterm.git"
Expand Down
38 changes: 33 additions & 5 deletions backend/wurm
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
#!/bin/bash

# Start nodejs server if needed, always start in background
if ! pgrep -f WurmTermBacken >/dev/null; then
(nohup node server.js >/dev/null 2>&1 &)
else
echo "Already running."
fi
start() {
if ! pgrep -f WurmTermBacken >/dev/null; then
# Locate source (either in <dirname>/../lib/node_modules or in same dir)
if [ "$(dirname $0)" = "/usr/local/bin" ]; then
cd /usr/local/lib/node_modules/wurmterm-backend
else
cd "$(dirname $0)"
fi

(nohup node server.js >/dev/null 2>&1 &)
echo "WurmTerm backend started."
else
echo "Already running."
fi
}

stop() {
if pgrep -f WurmTermBacken >/dev/null; then
echo "Stopping..."
pkill -fe WurmTermBacken
else
echo "Not running."
fi
}

case "${1-start}" in
start)
start
;;
stop)
stop
;;
esac

0 comments on commit f826245

Please sign in to comment.