[Freeswitch-dev] only one freeswitch at a time (using the same log directory, at least)
at one point Monday I accidentally launched a thousand freeswitch processes and crashed my box. Well that was dumb. But here is a patch to switch.c that makes freeswitch refuse to start if the process listed in freeswitch.pid is still running, and also does flock locking on the logfile to serialize the time between performing that check and writing our own pid there. -- "I've never been elected dog-catcher and I've never had an employee." -- Bruce Sterling
On 2/21/07, David Nicol <davidnicol@gmail.com> wrote:
at one point Monday I accidentally launched a thousand freeswitch processes and crashed my box. Well that was dumb. But here is a patch to switch.cthat makes freeswitch refuse to start if the process listed in freeswitch.pid is still running, and also does flock locking on the logfile to serialize the time between performing that check and writing our own pid there.
To anyone that runs multiple instances you want to ensure that the db dir isnt used by some other FS process as well. -- Trixter http://www.0xdecafbad.com Bret McDanel Belfast +44 28 9099 6461 US +1 516 687 5200 http://www.trxtel.com the VoIP provider that pays you!
On 2/21/07, Trixter aka Bret McDanel <trixter@0xdecafbad.com> wrote:
To anyone that runs multiple instances you want to ensure that the db dir isnt used by some other FS process as well.
there could be a multiple_instances WikiPage... my main concern is to avoid crashing the server again if I somehow manage to pull off another perl -le ' 1 while `/usr/local/freeswitch/bin/freeswitch -nc`' in which case i want to (1) serialize the start-ups to avoid race conditions and (2) error out when `cat /usr/local/freeswitch/log/freeswitch.pid` is still alive. MikeJ's requirement that the opening & locking get done with APR seems like a lot -- it means moving apr_initialize earlier than it would be otherwise; and I have stopped working on the apr port since I can't apparently get it to successfully open the file with apr_open. Current patch in jira. At your service (but not entirely, alas) David Nicol
On 2/21/07, David Nicol <davidnicol@gmail.com> wrote:
On 2/21/07, Trixter aka Bret McDanel <trixter@0xdecafbad.com> wrote:
To anyone that runs multiple instances you want to ensure that the db dir isnt used by some other FS process as well.
there could be a multiple_instances WikiPage...
my main concern is to avoid crashing the server again if I somehow manage to pull off another
perl -le ' 1 while `/usr/local/freeswitch/bin/freeswitch -nc`'
yeah, that is a potential issue, the patch I submitted to allow for specification to an alternate config should be consolodated, when I did it I didnt originally know that log, db and conf needed to be seperate, so I started out one at a time until I had all 3. Instead a better thing would be to edit switch.c (iirc) to have a -prefix-dir arg or something and use that so you specify one prefix which contains a conf,db,log dir. So if you are mucking about in the code to prevent multiple instances (remember the solution should be cross platform, mikej might be best to advise you on the windows way, but it shouldnt be a unix only solution, and cant rely on perl as things like pocket pc which is a supported platform dont have perl). It would be trivial to adjust the 3 'if' statements into one and adjust those 3 prefixes (they need to be the same format so they work on both windows and unix like systems - it was coded the way it was for that specific reason). Then just strncpy() + strcat() or whatever works the different subdirs to the specified main dir. That would make that part easier, and look much cleaner at the same time :D -- Trixter http://www.0xdecafbad.com Bret McDanel Belfast +44 28 9099 6461 US +1 516 687 5200 http://www.trxtel.com the VoIP provider that pays you!
participants (2)
-
David Nicol
-
Trixter aka Bret McDanel