本文整理汇总了PHP中cron::byId方法的典型用法代码示例。如果您正苦于以下问题:PHP cron::byId方法的具体用法?PHP cron::byId怎么用?PHP cron::byId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cron
的用法示例。
在下文中一共展示了cron::byId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
function remove()
{
$cron = cron::byId(config::byKey('xPLDeamonCronId', 'xPL'));
if (is_object($cron)) {
$cron->remove();
}
config::remove('xPLDeamonCronId', 'xPL');
}
示例2: foreach
<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">
示例3: array
$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());
}
示例4: poll
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;
}
}
}
示例5: sig_handler
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)) {