3

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 ?

Nikhil N
  • 4,507
  • 1
  • 35
  • 53
  • Have you already tried to remove `-nc` to not start in background mode? – Rob W Aug 24 '14 at 09:09
  • Not yet, trying it..is there any downside of not using -nc? – Nikhil N Aug 26 '14 at 17:25
  • 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 Aug 26 '14 at 18:13
  • @RobW Can you please your comment as answer? I would happy to assign bounty to it. Thanks. – Nikhil N Sep 01 '14 at 09:13
  • 1
    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 Sep 01 '14 at 09:15

2 Answers2

3

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.

  • With FreeSWITCH 1.6.8 and Supervisord 3.2.1, this did not work for me. What worked was adding the nofork option -- "-nc -nf -core". That has the additional advantage that it discards the standard output, which is what one would want since FreeSWITCH has its own logging machinery. – Manav May 25 '16 at 07:44
1

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.