【Linux】Ubuntu下安装并使用Supervisor守护gogs进程

安装

root@VM-0-14-ubuntu:~/gogs# apt-get install supervisor
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  python-meld3
Suggested packages:
  supervisor-doc
The following NEW packages will be installed:
  python-meld3 supervisor
0 upgraded, 2 newly installed, 0 to remove and 129 not upgraded.
Need to get 284 kB of archives.
After this operation, 1,552 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.tencentyun.com/ubuntu xenial/universe amd64 python-meld3 all 1.0.2-2 [30.9 kB]
Get:2 http://mirrors.tencentyun.com/ubuntu xenial-security/universe amd64 supervisor all 3.2.0-2ubuntu0.2 [253 kB]
Fetched 284 kB in 0s (747 kB/s) 
Selecting previously unselected package python-meld3.
(Reading database ... 74244 files and directories currently installed.)
Preparing to unpack .../python-meld3_1.0.2-2_all.deb ...
Unpacking python-meld3 (1.0.2-2) ...
Selecting previously unselected package supervisor.
Preparing to unpack .../supervisor_3.2.0-2ubuntu0.2_all.deb ...
Unpacking supervisor (3.2.0-2ubuntu0.2) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21.1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up python-meld3 (1.0.2-2) ...
Setting up supervisor (3.2.0-2ubuntu0.2) ...
Processing triggers for systemd (229-4ubuntu21.1) ...
Processing triggers for ureadahead (0.100.0-19) ...

启动服务


root@VM-0-14-ubuntu:~/gogs# service supervisor restart

加入gogs作为守护进程

gogs存在的目录 /root/gogs

修改之后的配置文件

[program:gogs]
command=/root/gogs/gogs web
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/gogs/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/gogs/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
user = root
environment = HOME="/root", USER="root"

内容写入文件 /etc/supervisor/conf.d/gogs.conf

载入配置

root@VM-0-14-ubuntu:/etc/supervisor/conf.d# supervisorctl reread
ERROR: CANT_REREAD: The directory named as part of the path /var/log/gogs/stdout.log does not exist. in section 'program:gogs' (file: '/etc/supervisor/conf.d/gogs.conf')
root@VM-0-14-ubuntu:/etc/supervisor/conf.d# mkdir /var/log/gogs
root@VM-0-14-ubuntu:/etc/supervisor/conf.d# supervisorctl reread
gogs: available

查看状态

root@VM-0-14-ubuntu:/etc/supervisor/conf.d# supervisorctl
gogs                             RUNNING   pid 13882, uptime 0:01:07

你可能感兴趣的:(#,linux环境)