프로그래밍/Front end
[Front end] 간단한 React 구동 Shell 스크립트
Reference M1
2021. 3. 24. 15:03
Jenkins (Exec command)
# dev,prod setting config
export NODE_ENV="dev"
echo $NODE_ENV
cd /svc/reference-m1
tar -xvf reference-m1.tar
sleep 5
#select node version
nvm use 14.15.4
#npm install
npm install
sleep 5
# run server
sh startReference-m1.sh > /dev/null 2>1 &
startReference-m1.sh
#!/bin/sh
APP_NAME="reference-m1"
APP_DESC="[reference-m1]"
# Process Check
sh /svc/reference-m1/stopReference-m1.sh
sleep 3
APP_PID=`ps -ef | grep ${APP_NAME} | grep -v vi | grep -v grep | awk '{print $2}'`
if [ -n "$APP_PID" ]
# Process Already Exist.
then
echo "======================================================="
echo " * Already Running! $APP_DESC - PID : "$APP_PID
echo "======================================================="
exit 1
# Process Not Exist.
else
cd /svc/reference-m1
if [ $NODE_ENV == "dev" ]
then
npm run dev
elif [ $NODE_ENV == "prod" ]
then
npm run prod
fi
echo "---------------[$NODE_ENV SERVER]-------------------"
echo " * Process Running! "$APP_DESC
fi
stopReference-m1.sh
#!/bin/sh
APP_NAME="reference-m1"
APP_DESC="[reference-m1]"
# Process Check
APP_PID=`ps -ef | grep ${APP_NAME} | grep -v vi | grep -v grep | awk '{print $2}'`
if [ -n "$APP_PID" ]
# Process Already Exist.
then
kill -9 $APP_PID
echo "======================================================="
echo " * Process Stopped! $APP_DESC - PID : "$APP_PID
echo "======================================================="
exit 1
# Process Not Exist.
else
echo "======================================================="
echo " * Already Stopped! No Process - "$APP_DESC
#echo "======================================================="
fi