64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
#!/usr/bin/php
|
|
<?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 {
|
|
$opts = new Zend_Console_Getopt(
|
|
//Options
|
|
array(
|
|
'help|?' => "Aide.",
|
|
)
|
|
);
|
|
$opts->parse();
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
echo $e->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
//Usage
|
|
if(isset($opts->help))
|
|
{
|
|
echo $opts->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
|
|
$db = Zend_Db::factory($c->resources->db);
|
|
$commandesM = new Application_Model_Commandes($db);
|
|
|
|
$sql = $commandesM->select()
|
|
->where('idProfil != ?', 0)
|
|
->where("dateStart != '0000-00-00 00:00:00'")
|
|
->where("dateStop = '0000-00-00 00:00:00'");
|
|
$result = $commandesM->fetchAll($sql);
|
|
if ( count($result)==0 ) {
|
|
|
|
//Si pas de traitement en cours alors on lance
|
|
$sql = $commandesM->select()
|
|
->where('idProfil != ?', 0)
|
|
->where("dateStart = '0000-00-00 00:00:00'")
|
|
->where("dateStop = '0000-00-00 00:00:00'")
|
|
->order('dateAdded ASC')->limit(1);
|
|
$result = $commandesM->fetchAll($sql);
|
|
if (count($result)>0) {
|
|
$info = $result->current();
|
|
echo date('Y-m-d H:i:s')." - Lancement enrichissement $info->id\n";
|
|
$c = new Zend_Config($application->getOptions());
|
|
$log = $c->profil->path->data.'/log/'.$info->id.'.log';
|
|
exec('php '.__DIR__."/jobs/enrichissement.php --id ".$info->id." 2>&1 >> ".$log." &");
|
|
}
|
|
|
|
} |