Skip to content

shell scripts

Murky edited this page Sep 10, 2019 · 4 revisions

Table of Contents

  1. Start Script
  2. Stop Script

Start Script

#! /bin/bash
  
clear

echo ""
echo "###########################"
echo "##   OPA APP Starting!   ##"
echo "###########################"
echo ""

APP_PATH="/home/ubuntu/opa-app"

echo "APP Path: $APP_PATH"

cd $APP_PATH
nohup yarn serve & > /dev/null #can use npm instead of yarn

Stop Script

#! /bin/bash
  
clear

echo ""
echo "###########################"
echo "##   OPA APP Stopping!   ##"
echo "###########################"
echo ""

PROCESS_NAME="things-factory"

echo "Process Name: $PROCESS_NAME"

PID=`/bin/ps -ef | grep $PROCESS_NAME | grep -v grep | awk '{print $2}'`
#if [ -z "$PID"]; then
#	echo "empty pid"
#fi
#echo $PID

while [[ ! -z "$PID" ]]
do
	kill -TERM $PID
	PID=`/bin/ps -ef | grep $PROCESS_NAME | grep -v grep | awk '{print $2}'`
done

echo "Done!"
Clone this wiki locally