Example #1
0
    if (in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
        echo "To clear the lock after a failed run, ";
        echo "pass in '--clearlock', '-clearlock', '-c' or '--c'." . PHP_EOL;
        exit("Bye!");
    } else {
        if (in_array($argv[1], array('--clearlock', '-clearlock', '-c', '--c'))) {
            if (is_process_lock("staticsync")) {
                clear_process_lock("staticsync");
            }
        } else {
            exit("Unknown argv: " . $argv[1]);
        }
    }
}
# Check for a process lock
if (is_process_lock("staticsync")) {
    echo 'Process lock is in place. Deferring.' . PHP_EOL;
    echo 'To clear the lock after a failed run use --clearlock flag.' . PHP_EOL;
    exit;
}
set_process_lock("staticsync");
echo "Preloading data... ";
$count = 0;
$done = sql_array("SELECT file_path value FROM resource WHERE LENGTH(file_path)>0 AND file_path LIKE '%/%'");
$done = array_flip($done);
# Load all modification times into an array for speed
$modtimes = array();
$resource_modified_times = sql_query("SELECT file_modified, file_path FROM resource WHERE archive=0 AND LENGTH(file_path) > 0");
foreach ($resource_modified_times as $rmd) {
    $modtimes[$rmd["file_path"]] = $rmd["file_modified"];
}
        $noimage = true;
        #
        $validargs = true;
    }
    if (in_array('-clearlock', $argv)) {
        if (is_process_lock("create_previews")) {
            clear_process_lock("create_previews");
        }
        $validargs = true;
    }
    if (!$validargs) {
        exit("Unknown argv: " . $argv[1]);
    }
}
# Check for a process lock
if (is_process_lock("create_previews")) {
    exit("Process lock is in place. Deferring.");
}
set_process_lock("create_previews");
if (function_exists("pcntl_signal")) {
    $multiprocess = true;
} else {
    $multiprocess = false;
}
// We store the start date.
$global_start_time = microtime(true);
// We define the number of threads.
$max_forks = 3;
$lock_directory = '.';
// We create an array to store children pids.
$children = array();
Example #3
0
	{
		if ( is_process_lock("checkmail") )
		{
			clear_process_lock("checkmail");
		}
	}
	else
	{
		exit("Unknown argv: " . $argv[1]);
	}
} 


# Check for a process lock
# This script checks one e-mail at a time.
if (is_process_lock("checkmail")) {
	if ($email_errors){
		send_mail($email_errors_address,$applicationname."- Checkmail blocked by process lock","Your IMAP account will not be checked until you clear this. An error may have caused this. Run the process manually with the -c switch to clear the lock and check for any errors.",$email_from);
	}
	exit("Process lock is in place. Deferring\r\n");
}
set_process_lock("checkmail");


// manually include plugin config since authenticate isn't being run
$config = sql_value("select config value from plugins where name='checkmail'","");
include_plugin_config("checkmail",$config);

$temp_dir=$storagedir."/tmp/checkmail_in";
if (!is_dir($temp_dir)){mkdir($temp_dir,0777);}
Example #4
0
	else if ( in_array($argv[1], array('--clearlock', '-clearlock', '-c', '--c')) )
	{
		if ( is_process_lock("staticsync") )
		{
			clear_process_lock("staticsync");
		}
	}
	else
	{
		exit("Unknown argv: " . $argv[1]);
	}
} 


# Check for a process lock
if (is_process_lock("staticsync")) {exit("Process lock is in place. Deferring.");}
set_process_lock("staticsync");

echo "Preloading data...";
$max=10000;
$count=0;

$done=sql_array("select file_path value from resource where length(file_path)>0 and file_path like '%/%'");

# Load all modification times into an array for speed
$modtimes=array();
$rd=sql_query("select ref,file_modified,file_path from resource where archive=0 and length(file_path)>0");
for ($n=0;$n<count($rd);$n++)
	{
	$modtimes[$rd[$n]["file_path"]]=$rd[$n]["file_modified"];
	}
Example #5
0
#!/usr/bin/php
<?php
include(dirname(__FILE__) . "/../include/db.php");
include(dirname(__FILE__) . "/../include/general.php");
include(dirname(__FILE__) . "/../include/image_processing.php");
include(dirname(__FILE__) . "/../include/resource_functions.php");

# Check for a process lock
if (is_process_lock("create_previews")) {exit("Process lock is in place. Deferring.");}
set_process_lock("create_previews");

if (function_exists("pcntl_signal")) {$multiprocess=true;} else {$multiprocess=false;}

// We store the start date.
$global_start_time = microtime(true);

// We define the number of threads.
$max_forks = 3;

$lock_directory = '.';

// We create an array to store children pids.
$children = array();

/**
 * This function clean up the list of children pids.
 * This allow to detect the freeing of a thread slot.
 */
function reap_children()
  {
  global $children;