? cvs-release-notes.php
Index: datasync.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/datasync/datasync.module,v
retrieving revision 1.1.4.19
diff -u -r1.1.4.19 datasync.module
--- datasync.module	24 Jul 2009 18:41:00 -0000	1.1.4.19
+++ datasync.module	24 Aug 2009 15:37:11 -0000
@@ -37,13 +37,32 @@
 }
 
 function datasync_cron() {
+  datasync_maintain_daemon();
+}
+
+/**
+ * Checks that the datasync_run.php script is running on this host. If not, starts it.
+ * 
+ * @param $http_host
+ *   The HTTP host that the CLI script should run Drupal with. 
+ */
+function datasync_maintain_daemon($http_host = NULL) {
   module_load_include('inc', 'datasync', 'datasync.hosts');
   $this_host = datasync_hostname();
+  global $datasync_debug;
   if (datasync_get_hosts($this_host) && 
        !($pid = ds_variable_get("datasync_pid_$this_host", 0)) || !datasync_process_running($pid)) {
     $command = 'php ' . drupal_get_path('module', 'datasync') . '/datasync_run.php';
-    $host = escapeshellcmd($_SERVER['HTTP_HOST']);
+    if ($http_host) {
+      $host = escapeshellcmd($http_host);
+    }
+    else {
+      $host = escapeshellcmd($_SERVER['HTTP_HOST']);
+    }
     $command .= " $host";
+    if ($datasync_debug) {
+      $command .= " debug";
+    }
     $pid = shell_exec("nohup $command > /dev/null & echo $!");
     $pid = trim($pid);
     ds_variable_set('datasync_pid_' . $this_host, $pid);
Index: datasync_run.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/datasync/Attic/datasync_run.php,v
retrieving revision 1.1.2.17
diff -u -r1.1.2.17 datasync_run.php
--- datasync_run.php	20 Aug 2009 14:35:49 -0000	1.1.2.17
+++ datasync_run.php	24 Aug 2009 15:37:11 -0000
@@ -306,15 +306,21 @@
     $mem_padding = ds_variable_get('datasync_host_memory_padding', 10485760); //10M in bytes
     $mem_lim = datasync_return_bytes(ini_get('memory_limit'));
 
-    if (
+    if (ds_variable_get("datasync_host_kill_$chost", 0)) {  //kill script if we are sent a signal
+      ds_variable_set("datasync_host_kill_$chost", 0);
+      exit(0);
+    }
+    else if (
         ((time()-$start) > 3600) //kill script every hour
     ||  (memory_get_usage() > ($mem_lim - $mem_padding)) //kill script if we are almost out of memory
-    ||  (ds_variable_get("datasync_host_kill_$chost", 0)) //kill script if we are sent a signal
        ) {
-      ds_variable_set("datasync_host_kill_$chost", 0);
+
+      // Spawn a new daemon before we finish
+      ds_variable_del("datasync_pid_$chost", 0);
+      datasync_maintain_daemon($host);
       exit(0);
     }
-    
+
     //exponential backoff
     datasync_debug("Sleeping for $wait seconds...");
     sleep($wait);
