鍍金池/ 問答/GO  網(wǎng)絡(luò)安全/ Supervisord 守護 golang 程序

Supervisord 守護 golang 程序

環(huán)境目錄

/home/wwwroot/api3/ 目錄下有以下 2 個文件 api-v3_linux_amd64go 編譯后的可執(zhí)行文件,程序執(zhí)行后 會取得當(dāng)前路徑下的 config.yaml 文件做為配置

[root]# ls
config.yaml
api-v3_linux_amd64

使用 nohup 后臺服務(wù)

nohup ./api-v3_linux_amd64 & 

使用 nohup 執(zhí)行后有時候 程序會 退出服務(wù),后來發(fā)現(xiàn)可以用 Supervisord 來做 Go 的 守護管理

使用 Supervisord 守護

[program:api3]                                                                                                               
user=root
directory=/home/wwwroot/api3/
command=api-v3_linux_amd64
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/root/Applications/LogFile/log/api3.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/root/Applications/LogFile/err/api3.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
stopsignal=INT
[supervisord]

go 加載配置文件

func init() {
    configor.Load(&Config, "config.yaml")
}

遇到問題

使用后 api-v3_linux_amd64 可執(zhí)行程序讀不到 當(dāng)前目錄下的 yaml 配置文件

感恩謝語

想請各位大佬 指點一下 , 感謝各位大佬,祝各位大佬 元旦快樂??!

回答
編輯回答
舊酒館

放到啟動參數(shù)里面吧

2018年7月28日 07:33
編輯回答
哚蕾咪

試試把directory=/home/wwwroot/api3/ 的最后一個斜杠去掉呢...還有就是檢查一下supervisor和config.yaml的權(quán)限...讀不到通常是路徑或者文件權(quán)限問題引起的

2017年5月17日 14:43