目前结构
$ tree /data/
/data
├── app
│ └── your-app
│ └── your-app-0.0.1-SNAPSHOT.jar
├── data
│ ├── your-app
├── etc
│ ├── common
│ ├── project
│ │ └── your-app
│ │ └── application.properties
│ └── supervisord
│ └── your-app.ini
├── logs
│ ├── your-app
│ │ ├── stderr.log
│ │ └── stdout.log
│ └── tomcat
│ ├── your_app_access_log.2019-02-28.log
│ └── your_app_access_log.2019-03-01.log
├── lost+found
└── web
└── your-app
└── start-web.sh
应用启动脚本
$ cat /data/web/your-app/start-web.sh
#!/bin/bash
read -r -d '' JMX <<- EOM
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=3000
EOM
read -r -d '' GC <<- EOM
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:-CMSConcurrentMTEnabled
-XX:CMSInitiatingOccupancyFraction=70
-XX:+CMSParallelRemarkEnabled
EOM
MEM="-Xms2G -Xmx2G"
CONF=/data/etc/project/your-app/application.properties
JAR=/data/app/your-app/your-app*.jar
cd $(dirname $0)
PORT=$1
if [ -z $PORT ]
then
PORT=8080
fi
java $MEM $GC -jar $JAR --server.port=$PORT --spring.config.location=$CONF
Supervisor 配置文件
$ chmod +x /data/web/your-app/start-web.sh
$ cat /data/etc/supervisord/your-app.ini
[program:your-app]
command=/data/web/your-app/start-web.sh 8080
killasgroup=true
stopasgroup=true
user=work
autostart=true
autorestart=true
stdout_logfile=/data/logs/your-app/stdout.log
stderr_logfile=/data/logs/your-app/stderr.log
stdout_logfile_maxbytes=100MB
stderr_logfile_maxbytes=100MB
启动服务
$ supvisorctl update/start your-app
your-app RUNNING pid 5474, uptime 1:14:46