[Server-devel] Ejabberd CPU/RAM Spike -> Crashes
Martin Langhoff
martin.langhoff at gmail.com
Mon Dec 21 17:31:46 EST 2009
On Mon, Dec 21, 2009 at 4:18 PM, crodas <crodas at paraguayeduca.org> wrote:
> According to the ticket the solution is a locking file which prevent the
> re-execution. Well, I've wrote a dumb script awhile ago that might help,
> it's not innovating, but it might help:
Thanks! The lock I coded is using a moodle-specific bit of code, so
it's in PHP, using moodle internal calls, and it uses PostgreSQL's
atomicity to achieve it in a non-racey way.
This has the advantage of locking a smaller bit of code -- not the
whole 'cron' run.
BTW, the lock script you're using is a bit racey (things could
definitely happen after the if [ -f $LOCK ]). If you want to do this
safely in shell scripting, using dotlockfile which is widely
available, even in oldish Linuxes. Recent Linuxes all include
/usr/bin/flock which is also sanely atomic, so that's what we use on
the XS for this task...
cheers,
m
--
martin.langhoff at gmail.com
martin at laptop.org -- School Server Architect
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff
More information about the Server-devel
mailing list