Supervisor 管理Java(JVM)启动进程

1.添加java 进程的配置文件

javaprogram.conf

[program:javaprogram]
directory = /home/substation_monitoring_system/
command = /usr/local/jdk-17.0.12/bin/java -jar /home/substation_monitoring_system/data_monitoring_system-0.1.32-Alpha-20250106.jar
autostart = true
stopsignal = INT
startsecs = 20
autorestart = true
startretries = 3
redirect_stderr=true
stdout_logfile_maxbytes = 10MB
stdout_logfile_backups = 10
stdout_logfile = /home/substation_monitoring_system/javaprogram.log

注意:上方标为红色的位置是需要修改的位置

2.文件目录结构:

/etc/supervisor/
├── asys.d
│   ├── clscript.conf
│   ├── javaprogram.conf
│   └── watchdog.conf
├── conf.d
│   ├── *(若干文件)
└── supervisord.conf

3.supervisord.conf文件内容

root@bzdtech:~# cat /etc/supervisor/supervisord.conf
; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[inet_http_server]         ; inet (TCP) server disabled by default
port=*:9001        ; (ip_address:port specifier, *:port for all iface)
username=root              ; (default is no username (open server))
password=666666               ; (default is no password (open server))


[supervisord]
logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info         ;
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)
minfds=81920
minprocs=81920


; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/asys.d/*.conf  /etc/supervisor/conf.d/*.conf

注意:javaprogram.conf 文件需要在include文件下

4.补充说明:

进程名称:自定义即可不要重复

Command:命令需要指定java安装目录下的全路径 修改环境变量的方式暂未实验成功

Stdoutlogfile:为进程标准输出的日志位置,自定义即可

posted @ 2025-01-08 16:29  BlackSnow  阅读(188)  评论(0)    收藏  举报