42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
use App\Application;
|
|
use Cake\Core\Configure;
|
|
use Cake\Core\Exception\MissingPluginException;
|
|
use Cake\Core\Plugin;
|
|
|
|
|
|
Configure::write('Log.error.file', 'cli-error');
|
|
|
|
try {
|
|
Application::addPlugin('Bake');
|
|
} catch (MissingPluginException $e) {
|
|
|
|
}
|
|
|
|
Application::addPlugin('Migrations');
|
|
|
|
function isLocked($lock_file) {
|
|
# If lock file exists, check if stale. If exists and is not stale, return TRUE
|
|
# Else, create lock file and return FALSE.
|
|
|
|
if( file_exists( $lock_file ) ) {
|
|
# check if it's stale
|
|
$lockingPID = trim( file_get_contents( $lock_file ) );
|
|
|
|
# Get all active PIDs.
|
|
$pids = explode( "\n", trim( `ps -e | awk '{print $1}'` ) );
|
|
|
|
# If PID is still active, return true
|
|
if( in_array( $lockingPID, $pids ) ) return true;
|
|
|
|
# Lock-file is stale, so kill it. Then move on to re-creating it.
|
|
//echo "Removing stale lock file.\n";
|
|
unlink( $lock_file );
|
|
}
|
|
|
|
file_put_contents( $lock_file, getmypid() . "\n" );
|
|
return false;
|
|
|
|
}
|