-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |