#! /bin/bash APP='eureka-1.0.0.jar' active='slave' pid=$(pgrep -f $APP) export JAVA_OPTS="-server -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC" start() { if [ -n "$pid" ]; then echo "[$APP] already start, pid:&pid" kill -9 $pid #return 0 fi #nohup java -jar $APP --spring.profiles.active=$active | /usr/sbin/cronolog eureka-$active-%Y-%m-%d.out >> /dev/null 2>&1 & ##日志切割 nohup java -jar $APP --spring.profiles.active=$active >> /dev/null & ##不保存启动日志 echo "[$APP] start, ok!" } stop() { if [ -z "$pid" ]; then echo "[$APP] not running!" #return 0 fi kill -9 $pid echo "[$APP] stop, ok!" } status() { if [ -z "$pid" ]; then echo "[$APP] not running!" else echo "[$APP] is running!" fi } case $1 in start) start ;; stop) stop ;; status) status ;; *) echo "Usage: {start|stop|status}" ;; esac exit 0