[xiph-commits] r14900 - branches/dir.xiph.org/cronjobs
balbinus at svn.xiph.org
balbinus at svn.xiph.org
Sat May 17 02:56:53 PDT 2008
Author: balbinus
Date: 2008-05-17 02:56:53 -0700 (Sat, 17 May 2008)
New Revision: 14900
Added:
branches/dir.xiph.org/cronjobs/check_servers.sh
Modified:
branches/dir.xiph.org/cronjobs/check_servers.php
Log:
Move the locking to a separate bash script.
Modified: branches/dir.xiph.org/cronjobs/check_servers.php
===================================================================
--- branches/dir.xiph.org/cronjobs/check_servers.php 2008-05-17 09:46:37 UTC (rev 14899)
+++ branches/dir.xiph.org/cronjobs/check_servers.php 2008-05-17 09:56:53 UTC (rev 14900)
@@ -10,15 +10,15 @@
{
throw new EnvironmentUndefinedException();
}
-$lock_file = '/tmp/'.ENVIRONMENT.'_check_servers.lock';
-if (file_exists($lock_file))
+/*$lock_file = '/tmp/'.ENVIRONMENT.'_check_servers.lock';
+if (1 && file_exists($lock_file))
{
- die("Another instance is already running.\n");
+ die("Another instance is already running.\n");
}
else
{
touch($lock_file);
-}
+}*/
// Database connection
$db = DirXiphOrgDBC::getInstance();
@@ -118,6 +118,8 @@
$sql = sprintf($sql, $res->current('id'));
$db->noReturnQuery($sql);*/
$server = Server::retrieveByPk($res->current('id'));
+ if ($server instanceOf Server)
+ {
$mp_id = $server->getMountpointId();
$mountpoint = Mountpoint::retrieveByPk($mp_id);
$server->remove();
@@ -126,6 +128,7 @@
{
$mountpoint->remove();
}
+ }
}
$res->next();
@@ -136,6 +139,6 @@
echo "OK.\n";
}
-unlink($lock_file);
+//unlink($lock_file);
?>
Added: branches/dir.xiph.org/cronjobs/check_servers.sh
===================================================================
--- branches/dir.xiph.org/cronjobs/check_servers.sh (rev 0)
+++ branches/dir.xiph.org/cronjobs/check_servers.sh 2008-05-17 09:56:53 UTC (rev 14900)
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+if [ -z "$ENVIRONMENT" ]
+then
+ echo "Environment undefined."
+ exit 1
+fi
+
+LOCKFILE=/tmp/${ENVIRONMENT}_check_servers.lock
+LOGFILE=/tmp/${ENVIRONMENT}_check_servers.log
+
+if [ -f "$LOCKFILE" ]
+then
+ echo "An instance is already running."
+ exit 2
+else
+ echo "Creating lockfile..."
+ touch "$LOCKFILE"
+ echo "Running check_servers.php..."
+ /usr/bin/php5 `dirname $0`/check_servers.php > $LOGFILE 2>&1
+ rm "$LOCKFILE"
+ echo "OK."
+fi
Property changes on: branches/dir.xiph.org/cronjobs/check_servers.sh
___________________________________________________________________
Name: svn:executable
+ *
More information about the commits
mailing list