jekins script deployment springboot

! # / bin / bash 
echo "STOP SpringBoot" 
pid = `PS -ef | grep ejoyst-bappapi-gateway.jar | grep -v grep | awk '{Print $ 2}' ` # discovery process and output port number 
echo "old application process the above mentioned id: $ pid " 
iF [-n" $ pid " ] # pid determine whether there is a non-cut 0 
the then 
the kill -9 $ pid # forcibly terminate processes 
fi

export JAVA_HOME=/usr/java/jdk1.8.0_161
 
 
echo ${JAVA_HOME}
 
 
echo "授权当前用户"
 
 
chmod 777 /opt/deploy/ejoyst-bappapi-gateway.jar
 
 
echo "执行...."
 
 
cd /opt/deploy/
 
 
nohup ${JAVA_HOME}/bin/java -jar ejoyst-bappapi-gateway.jar > /dev/null &
 
 
echo "启动成功"
 
nohup和&

Use & background to run the program:

  • The results will be output to the terminal

  • Use Ctrl + C SIGINT signal transmission, immunization program

  • Close session SIGHUP signal transmission, the program is closed

Use nohup to run the program:

  • The results will be output to the default nohup.out

  • Use Ctrl + C SIGINT signal transmission, the program is closed

  • Close session SIGHUP signal transmission, immunization program

Weekdays online often use nohup and & fit to start the program :

  • Meanwhile immune SIGINT and SIGHUP signal

At the same time, there is a best practice:

  • Do not output information to the terminal standard output, standard error, and use a logging component to log information to log

 

Guess you like

Origin www.cnblogs.com/lalalazar/p/12425888.html