GolangNote

Golang笔记

用Supervisor 守护Golang 应用进程的配置示例

Permalink

Supervisor 可以监控服务器的进程,并在出现问题是自动重启。用Supervisor 来守护Golang 应用进程是不错的选择。

Supervisor 守护Golang 应用

下面是一份用Supervisor 守护Golang 应用进程的配置:

INI: Supervisor 配置
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 转摘请注明来源

Related articles

Golang Web 程序生产环境独立部署示例

一个 web 应用通常是跑在一个前端代理,如 Nginx 后,这样可以方便的在同一个服务器部署多个应用。这里说的独立部署是指让 go web 程序直接暴露在外面,独占 443、80 端口(俗称裸跑)。这样做除了性能有些提高外,更重要的是部署方便。...

Golang http client 处理重定向网页

假设一个网址有多个重定向,A-B-C-D,使用 http.Client.Get 最后取得的内容是网址D的内容,我们该手动处理包含重定向的网址。...

Write a Comment to "用Supervisor 守护Golang 应用进程的配置示例"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.20 Processed in 1ms