run.sh

 

1.run.sh   文件  ./run.sh start启动    ./run.sh stop 停止    ./run.sh restart重启     ./run.sh install安装        ./run.sh uninstall卸载

#!/bin/bash
### BEGIN INIT INFO 
# Provides: Nginx
# Required-Start: $all 
# Required-Stop: $all 
# Default-Start: 3 5 
# Default-Stop: 0 1 6 
# Short-Description: Start and stop nginx mode 
# Description: Start and stop nginx in external FASTCGI mode 
### END INIT INFO 
# chkconfig: 2345 90 10
# description: nginx server daemon

dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

install()
{
echo "pass"
}

uninstall()
{
echo "pass"
}

start()
{
#port=$(grep server.port= application.properties |awk -F '=' '{printf $2}')
pid=$(ps -ef|grep $dir/package-all.jar|grep -v grep |awk '{printf $2}')
if [[ -n "$pid" ]];  then
  echo "$dir/package-all.jar is alredy running"
  exit 0
else
  nohup java -jar -Dspring.config.location=config/application.properties $dir/package-all.jar >/dev/null 2>&1 &
  exit 0
fi
}


stop()
{
pid=$(ps -ef|grep $dir/package-all.jar|grep -v grep |awk '{printf $2}')
if [[ -n "$pid" ]];  then
  kill -9 $pid
  exit 0
fi
}

restart()
{
stop
start
}

case $1 in
    'install')
       install
    ;;
    'uninstall')
       uninstall
    ;;
    'start')
       start
    ;;
    'stop')
       stop
    ;;
    'restart')
        restart
    ;;
    *)
    echo "Usage: $0 {install | uninstall | start | stop | restart}"
    exit 2
    ;;
esac
View Code

 

posted @ 2019-03-19 15:12  手中天  阅读(2486)  评论(0编辑  收藏  举报