如何为FreeSWITCH配置Supervisord?
我正在尝试配置一个Supervisor,用来控制FreeSWITCH。下面是目前在supervisord.conf
文件中的配置。
[program:freeswitch]
command=/usr/local/freeswitch/bin/freeswitch -nc -u root -g root
numprocs=1
stdout_logfile=/var/log/supervisor/freeswitch.log
stderr_logfile=/var/log/supervisor/freeswitch.log
autostart=true
autorestart=true
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600
; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true
当我使用supervisord
命令启动Supervisor时,它能正常启动freeswitch进程,没有任何错误。但是当我尝试用supervisorctl
命令重启freeswitch时,它却不工作,并且出现了以下错误。
freeswitch: ERROR (not running)
freeswitch: ERROR (abnormal termination)
我在日志文件(/var/log/supervisor/freeswitch.log)中没有看到任何错误报告。不过我看到以下内容:
1773 Backgrounding.
1777 Backgrounding.
1782 Backgrounding.
看起来它启动了三个freeswitch进程。这难道不对吗?
有没有人能指出这里的问题,并在需要时提供正确的配置?
2 个回答
1
要记住,进程会继承父进程的资源限制值(ulimits)。在你的情况下,freeswitch会和它的父进程supervisord使用相同的资源限制值……我觉得这对于像freeswitch这样需要大量资源的应用来说并不是你想要的。总的来说,使用supervisord来管理freeswitch其实是个很糟糕的主意。如果你非要用supervisord,那你需要查阅文档,看看怎么提高supervisord的所有资源限制值。
3
supervisor
要求运行的程序不能在后台运行;毕竟它的设计初衷就是为了处理那些不容易或者很难写成后台进程的程序。因此,当你用 supervisor
运行每个程序时,要确保它们不会在后台运行。
以 freeswitch 为例,只需去掉 -nc
这个选项,就可以让它在前台运行;这样 supervisor
会正确处理标准输入输出流,并在程序崩溃时自动重启它。