node service restart shell script

Node service restart script

restart.sh script

#!/bin/sh
 
NAME=HttpServer
PORT=$1
echo "input port =" $PORT
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
echo $ID
echo "restart---------------"
for id in $ID
do
kill -9 $id
echo "killed $id"
done
nohup node HttpServer --port=$PORT >> output.log &
echo "restart over---------------"

HttpServer is the service name of node,
bring the port number when running the startup script

 ./restart.sh 3000 

Guess you like

Origin blog.csdn.net/qq_36838406/article/details/124378778