[xiph-commits] r14712 - branches/dir.xiph.org/cronjobs

balbinus at svn.xiph.org balbinus at svn.xiph.org
Fri Apr 11 13:15:55 PDT 2008


Author: balbinus
Date: 2008-04-11 13:15:54 -0700 (Fri, 11 Apr 2008)
New Revision: 14712

Modified:
   branches/dir.xiph.org/cronjobs/check_servers.php
Log:
Added locking.

Modified: branches/dir.xiph.org/cronjobs/check_servers.php
===================================================================
--- branches/dir.xiph.org/cronjobs/check_servers.php	2008-04-11 19:12:18 UTC (rev 14711)
+++ branches/dir.xiph.org/cronjobs/check_servers.php	2008-04-11 20:15:54 UTC (rev 14712)
@@ -5,6 +5,21 @@
 
 class ToDeleteException extends Exception { }
 
+// Lock
+if (!defined('ENVIRONMENT'))
+{
+    throw new EnvironmentUndefinedException();
+}
+$lock_file = '/tmp/'.ENVIRONMENT.'_check_servers.lock';
+if (file_exists($lock_file))
+{
+    die("Another instance is already running.\n");
+}
+else
+{
+    touch($lock_file);
+}
+
 // Database connection
 $db = DirXiphOrgDBC::getInstance();
 
@@ -112,4 +127,6 @@
     echo "OK.\n";
 }
 
+unlink($lock_file);
+
 ?>



More information about the commits mailing list