티스토리 뷰

 

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

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함