Supervisor 可以监控服务器的进程,并在出现问题是自动重启。用Supervisor 来守护Golang 应用进程是不错的选择。
下面是一份用Supervisor 守护Golang 应用进程的配置:
1
2
3
4
5
6
7
8
9
10
11
12
[program:yourapp]
command=/home/yourappuser/bin/yourapp # the location of your app
autostart=true
autorestart=true
startretries=10
user=yourappuser # the user your app should run as (i.e. *not* root!)
directory=/srv/www/yourapp.com/ # where your application runs from
environment=APP_SETTINGS="/srv/www/yourapp.com/prod.toml" # environmental variables
redirect_stderr=true
stdout_logfile=/var/log/supervisor/yourapp.log # the name of the log file.
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
本文网址: https://golangnote.com/topic/20.html 转摘请注明来源