When we deploy the server, we need to do a startup script to make it easy for us to start/Shut down the server.
Here I give a pro-test script file,
The script is a script to start node, the principle is to start the execution of the start command, the resulting number is written to the file, and then stop the time to remove the PID from the file, and then kill it. Finally, the process is erased.
#! /bin/sh node_env=production daemon= "Node cluster.js" NAME= Fruitpoint desc=fruitpoint pidfile= "Fruitpoint.pid" case "$" in start) echo "starting $ desc: " nohup $DAEMON > /dev/null & echo $! > $ Pidfile echo "$NAME.";; Stop) echo "stopping $DESC: " cat $PIDFILE |while read line ; do echo $line kill $line done rm $PIDFILE echo "$NAME.";; Esac exit 0
Place the script file in the project root directory, start./file name start close./File name stop
Learning-"front-end"-Server script writing