由于linux的rc.local命令方式启动gogs可能会遇到各种问题,再加上官方给出了supervisor方式的设置文件,因此用supervisor对gogs进行管理是更好的选择。
首先,我们要安装supervisor
apt install supervisor
安装完成后在/etc/supervisor/conf.d下放置gogs的配置文件,文件位置在gogs目录下/scripts/supervisor/gogs。直接拷贝到目标目录,并进行相应修改:
[program:gogs]
directory=/home/git/go/src/github.com/gogits/gogs/ ;gogs程序目录位置,改成相应的目录
command=/home/git/go/src/github.com/gogits/gogs/gogs web ;gogs启动命令,记得改成相应的目录
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/gogs/stdout.log ;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 = git
environment = HOME="/home/git", USER="git" ;家目录位置,和运行用户的身份,和gogs配置文件的位置保持一致
之后我们重启supervisor使配置文件生效:
service supervisor restart
然后就可以使用supervisor控制shadowsocks了:
supervisorctl start shadowsocks
supervisorctl start shadowsocks
大家可以重启下系统看看shadowsocks是否自动重新启动:
sudo reboot