首页 > 代码库 > ubuntu部署supersor

ubuntu部署supersor

 1、安装pip

$ sudo apt-get install python-pip –y
$ sudo pip install  - -upgrade pip          //升级pip

 

2、安装supervisor

$ sudo pip install supervisor

 

3、建立配置文件存放目录

$ sudo mkdir –p /etc/supervisor/conf.d

 

4、 将默认配置导入supervisor.conf文件里,以下命令需用root执行

$ sudo -i                                //切换到用户root
# echo_supervisord_conf > /etc/supervisor/supervisor.conf

 

5、 修改配置文件

$ sudo vim /etc/supervisor/supervisor.conf

 ----------------------------------------------------------------->

#开启web连接,并设置用户和密码,0.0.0.0表示放行所有IP
[inet_http_server]       ; inet (TCP) server disabled by default
port=0.0.0.0:9001       ; ip_address:port specifier, *:port for all iface
username=admin       ; default is no username (open server)
password=123456       ; default is no password (open server)

#修改配置文件路径与类型
[include]
files = conf.d/*.conf

 

6、 新建一个java配置

$ sudo vim /etc/supervisor/conf.d/java.conf

 --------------------------------------------------------------------->

[program:java]
command=/usr/bin/java -jar /data/www/room/devshixin.jar              ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s         ; process_name expr (default %(program_name)s)
;numprocs=1                            ; number of processes copies to start (def 1)
;directory=/tmp                        ; directory to cwd to before exec (def no cwd)
;umask=022                             ; umask for process (default None)
;priority=999                          ; the relative start priority (default 999)
autostart=true                         ; start at supervisord start (default: true)
;startsecs=1                           ; # of secs prog must stay up to be running (def. 1)
;startretries=3                        ; max # of serial start failures when starting (default 3)
autorestart=unexpected                 ; when to restart if exited after running (def: unexpected)
;exitcodes=0,2                          ; ‘expected‘ exit codes used with autorestart (default 0,2)
;stopsignal=QUIT                        ; signal used to kill process (default TERM)
;stopwaitsecs=10                       ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false                      ; send stop signal to the UNIX process group (default false)
;killasgroup=false                     ; SIGKILL the UNIX process group (def false)
;user=chrism                            ; setuid to this UNIX account to run the program
;redirect_stderr=true                   ; redirect proc stderr to stdout (default false)
stdout_logfile=/var/log/dev_room.log        ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=1MB             ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=10             ; # of stdout logfile backups (0 means none, default 10)
;stdout_capture_maxbytes=1MB            ; number of bytes in ‘capturemode‘ (default 0)
;stdout_events_enabled=false           ; emit events on stdout writes (default false)
stderr_logfile=/var/log/err_dev_room.log    ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=1MB           ; max # logfile bytes b4 rotation (default 50MB)
stderr_logfile_backups=10              ; # of stderr logfile backups (0 means none, default 10)
;stderr_capture_maxbytes=1MB           ; number of bytes in ‘capturemode‘ (default 0)
;stderr_events_enabled=false           ; emit events on stderr writes (default false)
;environment=A="1",B="2"               ; process environment additions (def no adds)
;serverurl=AUTO                        ; override serverurl computation (childutils)

 

7、 启动supervisor

$ supervisor –c /etc/supervisor/supervisor.conf

 

8、 启动服务并添加开机启动

#启动服务
$ /usr/local/bin/supervisord -c /etc/supervisor/supervisor.conf

#添加开机启动
$ sudo vim /etc/rc.local
---------------------------------->
/usr/local/bin/supervisord –c /etc/supervisor/supervisor.conf

 

9、 网页访问supervisor

技术分享

技术分享

 

ubuntu部署supersor