刘光辉
6 小时以前 1c0304091d5a7dd05859167f5e417cf932c67028
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
app='jnpf-workflow-admin-1.0.0-RELEASE.jar'
args=' -Xms600m -Xmx600m --add-opens java.base/java.lang=ALL-UNNAMED -XX:+DisableAttachMechanism '
cmd=$1
pid=`ps -ef|grep java|grep $app|awk '{print $2}'`
 
startup(){
  nohup java $args -jar $app >Log.log 2>&1 &
}
 
if [ ! $cmd ]; then
  echo "Please specify args 'start|restart|stop'"
  exit
fi
 
if [ $cmd == 'start' ]; then
  if [ ! $pid ]; then
    startup
  else
    echo "$app is running! pid=$pid"
  fi
fi
 
if [ $cmd == 'restart' ]; then
  if [ $pid ]
    then
      echo "$pid will be killed after 3 seconds!"
      sleep 3
      kill -9 $pid
  fi
  startup
fi
 
if [ $cmd == 'stop' ]; then
  if [ $pid ]; then
    echo "$pid will be killed after 3 seconds!"
    sleep 3
    kill -9 $pid
  fi
  echo "$app is stopped"
fi