Menu

#10 consolidate.php - is_process_running bug

closed
None
5
2012-09-18
2006-01-05
blentz
No

Due to the length of time it takes for sms_client to
page all the required recipients in the event of a
trigger in my configuration, my consolidate.php cron
process can take more than a minute to run.

My problem is that when an alarm is triggered, I often
end up with more than one consolidate.php process
running at a time, and all hell breaks loose: Multiple
notifications for the same event go out, multiple
processes are waiting for the sms_client to free up the
modem, etc.

The engine/consolidate.php process uses the function
is_process_running() from lib/api.inc.php to prevent
multiple runs of consolidate.php from being executed
simultaneously by cron. However, this function doesn't
work... consolidate.php calls is_process_running() with
(NULL,2) and in lib/api.inc.php, if $process_name isn't
specified (i.e. NULL), it fails back to the
$_SERVER["PHP_SELF"] variable. It looks like this
variable is only available when executed from apache,
and is not set when consolidate.php is run from cron...
I've done some simple tests and each time the
$_SERVER["PHP_SELF"] variable is empty when I run
things from bash (assuming it's the same with cron).

My workaround is to modify engine/consolidate.php to be
more specific about how it specifies the
is_process_running() test:
--- engine/consolidate.php.orig 2006-01-05
11:45:31.581210320 -0500
+++ engine/consolidate.php 2006-01-05
11:11:27.630937992 -0500
@@ -16,7 +16,7 @@
$i = 0;
$date_start = time();

  • if (is_process_running(NULL,2) === false) {
    //check if a process named as myself is already
    running (one instance is me)
  • if (is_process_running("consolidate.php",2) ===
    false) { //check if a process named as myself is
    already running (one instance is me)

    detach();

Perhaps there's a more robust solution for fixing this
problem (i.e. perhaps better self-> detection in
lib/api.inc.php) but this works for me and properly
prevents consolidate.php from running more than once.
Hell is no longer breaking loose...

So long as I don't have another process running on my
box with that same name ;-)

Discussion

  • blentz

    blentz - 2006-01-05

    Patch for engine/consolidate.php

     
  • Craig Small

    Craig Small - 2008-11-08

    Hello,
    I know this is a pretty old bug but can you tell me if you still have this problem? I have just checked for myself and
    I am getting consolidate.php appearing even on the command line. This problem sounds more like some quirk in a specific version of PHP rather than in JFFNMS.

    • Craig
     
  • Craig Small

    Craig Small - 2011-02-17

    Missed this bug but it has been fixed for a while now. The code uses $_SERVER['PHP_SELF'] now which is defined on the command line.

     

Anonymous
Anonymous

Add attachments
Cancel