3
votes

I am trying to configure a Supervisor for controlling the FreeSWITCH. Following is the configuration at this moment present in 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

When I an starting the supervisor using supervisord command, it starts the freeswitch process without any error. But when I am trying to restart the freeswitch using supervisorctl command, its not working and giving following errors.

freeswitch: ERROR (not running)
freeswitch: ERROR (abnormal termination)

I am not able to see any error reported in log(/var/log/supervisor/freeswitch.log). However I am seeing following:

1773 Backgrounding.
1777 Backgrounding.
1782 Backgrounding.

It seems its starting three process of freeswitch. Isn't this wrong?

Can someone point out what's problem here and provide correct configuration if require ?

2
Have you already tried to remove -nc to not start in background mode?Rob W
Not yet, trying it..is there any downside of not using -nc?nik
Not that I'm aware of. I usually start freeswitch in screen, so it's easy to SSH to the server and immediately interact with FS (like fs_cli).Rob W
@RobW Can you please your comment as answer? I would happy to assign bounty to it. Thanks.nik
Antti Haapala's answer already contains my comment, so I don't see a point in posting it again. Glad to have helped!Rob W

2 Answers

3
votes

supervisor requires that the run programs do not fork to background; after all it was created to run as background processes those programs for which it would be infeasible or difficult to make correctly daemonising code. Thus for each program you run with supervisor, make sure that it does not fork on background.

In the case of freeswitch, just remove the -nc option to cause it run on foreground; supervisor will direct the standard streams appropriately and restart the process if it crashed.

1
votes

keep in mind that processes inherit the ulimits values of the parent process, so in your case freeswitch will run with the same ulimits as its parent process supervisord ... which I don't think is what you would want for a ressource intensive application such as freeswitch, this said using supervisord with freeswitch is actually a very bad idea. if you must stick to it, then you will have to find out in the documentation how to raise all of ulimit values for supervisord.