Skip to content

Commit

Permalink
Merge pull request #27 from nalbam/main
Browse files Browse the repository at this point in the history
v0.5.2 pm2
  • Loading branch information
nalbam authored Nov 11, 2023
2 parents 9e78b46 + 57bfa70 commit 9f41116
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deepracer-timer",
"version": "v0.5.1",
"version": "v0.5.2",
"description": "Node.js deepracer-timer",
"main": "server.js",
"dependencies": {
Expand Down
57 changes: 21 additions & 36 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,46 +66,28 @@ _usage() {
}

_stop() {
_pid

if [ "${PID}" != "" ]; then
_command "kill -9 ${PID}"
kill -9 ${PID}

_result "deepracer-timer is killed: ${PID}"
fi
}
pushd ${SHELL_DIR}

_status() {
_pid
sudo pm2 stop server.js

if [ "${PID}" != "" ]; then
_result "deepracer-timer was started: ${PID}"
else
_result "deepracer-timer is stopped"
fi
popd
}

_start() {
_pid

if [ "${PID}" != "" ]; then
_error "deepracer-timer has already started: ${PID}"
fi

pushd ${SHELL_DIR}

echo "# _start" >nohup.out
_command "nohup node server.js &"
nohup node server.js &
sudo pm2 start server.js
sudo pm2 save

popd
}

_pid
_status() {
sudo pm2 list
}

if [ "${PID}" != "" ]; then
_result "deepracer-timer was started: ${PID}"
fi
_log() {
sudo pm2 logs
}

_init() {
Expand All @@ -115,6 +97,13 @@ _init() {
sudo apt install -y nodejs
fi

command -v pm2 >/dev/null || PM2="false"
if [ "${PM2}" == "false" ]; then
sudo npm install pm2 -g
fi

sudo pm2 startup

pushd ${SHELL_DIR}
git pull
npm run build
Expand All @@ -125,19 +114,12 @@ _hangul() {
sudo apt install -y ibus ibus-hangul fonts-unfonts-core
}

_log() {
tail -n 500 -f ${SHELL_DIR}/nohup.out
}

case ${CMD} in
init)
_stop
_init
_start
;;
status)
_status
;;
start)
_start
;;
Expand All @@ -148,6 +130,9 @@ restart)
stop)
_stop
;;
status)
_status
;;
log)
_log
;;
Expand Down
1 change: 1 addition & 0 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</div>
<div class="lb-title">
<a href="/timer" class="btn-link">Timer</a>
<a href="https://dracer.io" class="btn-link">Board</a>
</div>
</body>

Expand Down

0 comments on commit 9f41116

Please sign in to comment.