Skip to content

Commit

Permalink
Merge pull request #18 from nalbam/main
Browse files Browse the repository at this point in the history
add usage
  • Loading branch information
nalbam authored Oct 13, 2023
2 parents 6e6022e + de79398 commit f3ba007
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
## usage

```bash
./run.sh init
git clone https://github.com/aws-deepracer-community/deepracer-timer.git

./deepracer-timer/run.sh init
./run.sh start
./run.sh restart
./run.sh status
Expand Down
36 changes: 30 additions & 6 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

SHELL_DIR=$(dirname $0)

CMD=${1:-status}
CMD=${1}

command -v tput >/dev/null || TPUT=false

_bar() {
_echo "================================================================================"
}

_echo() {
if [ -z ${TPUT} ] && [ ! -z $2 ]; then
echo -e "$(tput setaf $2)$1$(tput sgr0)"
Expand Down Expand Up @@ -40,12 +44,29 @@ _error() {
exit 1
}

_get_pid() {
_pid() {
PID=$(ps -ef | grep node | grep " server[.]js" | head -1 | awk '{print $2}' | xargs)
}

################################################################################

_usage() {
_bar
echo " _ _ _ "
echo " __| | ___ ___ _ __ _ __ __ _ ___ ___ _ __ | |_(_)_ __ ___ ___ _ __ "
echo " / _ |/ _ \/ _ \ '_ \| '__/ _' |/ __/ _ \ '__| | __| | '_ ' _ \ / _ \ '__| "
echo "| (_| | __/ __/ |_) | | | (_| | (_| __/ | | |_| | | | | | | __/ | "
echo " \__,_|\___|\___| .__/|_| \__,_|\___\___|_| \__|_|_| |_| |_|\___|_| "
echo " |_| "
_bar
echo " Usage: ./$(basename $0) {init|status|start|restart|stop|log} "
_bar
_status
_bar
}

_stop() {
_get_pid
_pid

if [ "${PID}" != "" ]; then
_command "kill -9 ${PID}"
Expand All @@ -56,7 +77,7 @@ _stop() {
}

_status() {
_get_pid
_pid

if [ "${PID}" != "" ]; then
_result "deepracer-timer was started: ${PID}"
Expand All @@ -66,7 +87,7 @@ _status() {
}

_start() {
_get_pid
_pid

if [ "${PID}" != "" ]; then
_error "deepracer-timer has already started: ${PID}"
Expand All @@ -80,7 +101,7 @@ _start() {

popd

_get_pid
_pid

if [ "${PID}" != "" ]; then
_result "deepracer-timer was started: ${PID}"
Expand Down Expand Up @@ -120,4 +141,7 @@ stop)
log)
_log
;;
*)
_usage
;;
esac

0 comments on commit f3ba007

Please sign in to comment.