Prise en compte des particularités de incrontab

This commit is contained in:
Michael RICOIS 2015-10-14 13:16:14 +00:00
parent 56c50f898c
commit 1898511d11
3 changed files with 67 additions and 0 deletions

5
README
View File

@ -56,6 +56,11 @@ $fluxBasePath IN_ACCESS php /home/batchFlux/fileRead.php --file $@/$# >> /home/l
Exemple surveillance retour par autre programme de transmission
$fluxBasePath IN_CLOSE_WRITE php /home/batchFlux/fileTck.php --file $@/$# >> /home/log/tck.log 2>&1
Attention, une seule entrée de repertoire peut être saisie dans la incrontab.
fileSend a été prévue pour faire gérer correctement les extension tck
Sinon préférer l'utilisation de trigger.php
$fluxBasePath IN_CLOSE_WRITE,IN_ACCESS,IN_DELETE,IN_NO_LOOP /home/batchFlux/trigger.php --file $@/$# --event $%
TODO
====

View File

@ -67,6 +67,7 @@ if ( isset($opts->file) )
}
// --- Don't play with *.tck files
if ($extension == 'tck') {
passthru(__DIR__ . '/fileTck.php --file '.$opts->file.' >> /home/log/tck.log 2>&1');
exit;
}
$client = basename(dirname($pathParts['dirname']));

61
trigger.php Normal file
View File

@ -0,0 +1,61 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/application'));
// --- Define application environment
defined('APPLICATION_ENV')
| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
try {
// --- Options
$opts = new Zend_Console_Getopt(array(
'help|?' => "Displays usage information.",
'file|f=s' => "Full file path to integrate",
'event=s' => "Event",
));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
// --- Usage
if( isset($opts->help) || count($opts->getOptions())==0 )
{
echo "Proxy Event Trigger.\n";
echo $opts->getUsageMessage();
exit;
}
// --- Basic file information
if (empty($opts->file)) {
exit;
}
$pathParts = pathinfo($opts->file);
$filename = $pathParts['basename'];
$extension = $pathParts['extension'];
switch($opts->event)
{
case 'IN_CLOSE_WRITE':
if ($extension == 'tck') {
passthru(__DIR__ . '/fileTck.php --file '.$opts->file.' >> /home/log/tck.log 2>&1');
} else {
passthru(__DIR__ . '/fileSend.php --file '.$opts->file.' >> /home/log/send.log 2>&1');
}
break
case 'IN_ACCESS':
passthru(__DIR__ . '/fileRead.php --file '.$opts->file.' >> /home/log/read.log 2>&1');
break;
case 'IN_DELETE':
passthru(__DIR__ . '/fileRead.php --file '.$opts->file.' >> /home/log/read.log 2>&1');
break;
}