node 服务重启shell 脚本

node 服务重启脚本

restart.sh 脚本

#!/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 是node的服务名名称,
运行启动脚本时带上端口号

 ./restart.sh 3000 

猜你喜欢

转载自blog.csdn.net/qq_36838406/article/details/124378778