Exemple #1
0
function remove()
{
    $cron = cron::byId(config::byKey('xPLDeamonCronId', 'xPL'));
    if (is_object($cron)) {
        $cron->remove();
    }
    config::remove('xPLDeamonCronId', 'xPL');
}
Exemple #2
0
                <li class="nav-header">Liste des équipements xPL 
                    <i class="fa fa-plus-circle pull-right cursor eqLogicAction" data-action="add" style="font-size: 1.5em;margin-bottom: 5px;"></i>
                </li>
                <li class="filter" style="margin-bottom: 5px;"><input class="filter form-control input-sm" placeholder="Rechercher" style="width: 100%"/></li>
                <?php 
foreach (eqLogic::byType('xpl') as $eqLogic) {
    echo '<li class="cursor li_eqLogic" data-eqLogic_id="' . $eqLogic->getId() . '"><a>' . $eqLogic->getHumanName() . '</a></li>';
}
?>
            </ul>
        </div>
    </div>

    <div class="col-lg-10 eqLogic" style="border-left: solid 1px #EEE; padding-left: 25px;display: none;">
        <?php 
$cron = cron::byId(config::byKey('xPLDeamonCronId', 'xPL'));
if (is_object($cron) && $cron->getState() != 'run') {
    echo '<div class="alert alert-danger" >Attention le démon xPL n\'est pas en marche. Vérifiez pourquoi. </div>';
}
?>
        <form class="form-horizontal">
            <fieldset>
                <legend>Général</legend>
                <div class="form-group">
                    <label class="col-lg-3 control-label">Nom de l'équipement xPL</label>
                    <div class="col-lg-3">
                        <input type="text" class="eqLogicAttr form-control" data-l1key="id" style="display : none;" />
                        <input type="text" class="eqLogicAttr form-control" data-l1key="name" placeholder="Nom de l'équipement xPL"/>
                    </div>
                </div>
                <div class="form-group">
Exemple #3
0
        $results = array();
        $results['crons'] = utils::o2a(cron::all(true));
        $results['nbCronRun'] = cron::nbCronRun();
        $results['nbProcess'] = cron::nbProcess();
        $results['nbMasterCronRun'] = cron::jeeCronRun() ? 1 : 0;
        $results['loadAvg'] = cron::loadAvg();
        ajax::success($results);
    }
    if (init('action') == 'start') {
        $cron = cron::byId(init('id'));
        if (!is_object($cron)) {
            throw new Exception(__('Cron id inconnu', __FILE__));
        }
        $cron->run();
        sleep(1);
        ajax::success();
    }
    if (init('action') == 'stop') {
        $cron = cron::byId(init('id'));
        if (!is_object($cron)) {
            throw new Exception(__('Cron id inconnu', __FILE__));
        }
        $cron->halt();
        sleep(1);
        ajax::success();
    }
    throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
 private function poll()
 {
     if (!$this->attached()) {
         $this->sendHeartbeat();
         $this->retryConnectToHub++;
         if ($this->retryConnectToHub > XPL_MAX_RETRY_CONNEXION_TO_HUB) {
             log::add('xpl', 'error', 'xPL Hub non trouvé, veuillez le redemarrer');
             $cron = cron::byId(config::byKey('xPLDeamonCronId', 'xPL'));
             if (is_object($cron)) {
                 $cron->setEnable(0);
                 $cron->save();
                 $cron->stop();
             }
         }
         return;
     }
     $this->retryConnectToHub = 0;
     if (time() - $this->thisDevice->lastHeartBeat() >= $this->thisDevice->heartBeatInterval() * 60) {
         $this->sendHeartbeat();
     }
     //Loop all devices to see if they have timed out
     foreach ($this->devices as $key => $device) {
         if (time() - $device->lastHeartBeat() >= $device->heartBeatInterval() * 60 * 2) {
             log::add('xpl', 'info', 'Device removed (timeout) : ' . $device->deviceName());
             //This is not a prefeered way of removing the item from an array
             //Since we are iterating the loop will miss to check the new item.
             //Here, it will be checked next time poll is called
             unset($this->devices[$key]);
             xPL::removedDeviceFromxPLNetwork($device->deviceName());
             continue;
         }
     }
 }
Exemple #5
0
function sig_handler($signo)
{
    global $SIGKILL;
    $SIGKILL = true;
}
// Installation des gestionnaires de signaux
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
pcntl_signal(SIGUSR1, "sig_handler");
if (init('cron_id') != '') {
    if (config::byKey('enableCron', 'core', 1, true) == 0) {
        die(__('Tous les crons sont actuellement désactivés', __FILE__));
    }
    $datetime = date('Y-m-d H:i:s');
    $datetimeStart = strtotime('now');
    $cron = cron::byId(init('cron_id'));
    if (!is_object($cron)) {
        echo 'Cron non trouvé';
        die;
    }
    try {
        $cron->setState('run');
        $cron->setDuration('0s');
        $cron->setPID(getmypid());
        $cron->setLastRun($datetime);
        $cron->save();
        $option = $cron->getOption();
        if ($cron->getClass() != '') {
            $class = $cron->getClass();
            $function = $cron->getFunction();
            if (class_exists($class) && method_exists($class, $function)) {