nexus+jar包 跟随系统开机启动:
nexus+jar包开机启动:
方法一 : chkconfig
vi /usr/local/nexus/nexus-2.14.13-01/bin/jsw/conf/wrapper.conf
wrapper.java.command=/usr/local/jdk1.8.0_201/bin/java
vi /etc/init.d/nexus
#!/bin/bash
#chkconfig:2345 20 90
#description:nexus
#processname:nexus
export JAVA_HOME=/usr/local/jdk1.8.0_201
case $1 in
start) su root /usr/local/nexus/nexus-2.14.13-01/bin/nexus start;;
stop) su root /usr/local/nexus/nexus-2.14.13-01/bin/nexus stop;;
status) su root /usr/local/nexus/nexus-2.14.13-01/bin/nexus status;;
restart) su root /usr/local/nexus/nexus-2.14.13-01/bin/nexus restart;;
dump) su root /usr/local/nexus/nexus-2.14.13-01/bin/nexus dump;;
console) su root /usr/local/nexus/nexus-2.14.13-01/bin/nexus console;;
*) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
esac
chmod 777 /etc/init.d/nexus
service nexus status
chkconfig --add nexus
chkconfig nexus on
chkconfig --list nexus
init 6 试一下
================================================
方法二:systemctl
vi /usr/local/nexus/nexus-2.14.13-01/bin/jsw/conf/wrapper.conf
wrapper.java.command=/usr/local/jdk1.8.0_201/bin/java
[Unit]
Description=nexus
After=network.target
[Service]
User=nexus
Type=forking
ExecStart=/usr/local/nexus/nexus-2.14.13-01/bin/nexus start
ExecReload=/usr/local/nexus/nexus-2.14.13-01/bin/nexus restart
ExecStop=/usr/local/nexus/nexus-2.14.13-01/bin/nexus stop
Restart=on-abort
[Install]
WantedBy=multi-user.target
========================================================
jar包 跟系统启动:
#! /bin/bash
pid=`ps -ef | grep gateway-1.0.0.jar | grep -v grep | awk '{print $2}'`
echo "$pid"
if [ -z "$pid" ]
then
echo "service is already stopped"
else
kill -TERM $pid
echo "service is killed"
fi
exec /usr/local/jdk/jdk1.8.0_201/bin/java -DGATEWAY_HOME=/usr/local/gateway -Dfile.encoding=utf-8 -jar /usr/local/gateway/gateway-1.0.0.jar -logfile=/usr/local/gateway/nohup.out
=========================================================
#! /bin/bash
pid=`ps -ef | grep gateway-1.0.0.jar | grep -v grep | awk '{print $2}'`
echo "$pid"
if [ -z "$pid" ]
then
echo "service is already stopped"
else
kill -TERM $pid
echo "service is killed"
fi
==================================================
[Unit]
Description=Gateway Application
After=network.target
[Service]
User=root
WorkingDirectory=/usr/local/gateway
ExecStart=/bin/bash /usr/local/gateway/start.sh
ExecStop=/bin/bash /usr/local/gateway/stop.sh
Restart=on-failure
Environment=JAVA_HOME=/usr/local/jdk/jdk1.8.0_201/bin/java
[Install]
WantedBy=multi-user.target
==========================================================
nginx
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target