本文整理汇总了PHP中Scalr::FireDeferredEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr::FireDeferredEvent方法的具体用法?PHP Scalr::FireDeferredEvent怎么用?PHP Scalr::FireDeferredEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr
的用法示例。
在下文中一共展示了Scalr::FireDeferredEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Run
public function Run()
{
$DB = \Scalr::getDb();
$dbevent = $DB->GetRow("SELECT * FROM events WHERE id=?", array($this->EventID));
if ($dbevent) {
try {
//TODO: Initialize Event classes
$Event = unserialize($dbevent['event_object']);
if ($Event) {
Logger::getLogger(__CLASS__)->info(sprintf(_("Fire event %s for farm: %s"), $Event->GetName(), $Event->GetFarmID()));
// Fire event
Scalr::FireDeferredEvent($Event);
}
$DB->Execute("UPDATE events SET ishandled='1', event_object = '' WHERE id=?", array($dbevent['id']));
} catch (Exception $e) {
Logger::getLogger(__CLASS__)->fatal(sprintf(_("Cannot fire deferred event: %s"), $e->getMessage()));
}
}
return true;
}
示例2: OnStartForking
public function OnStartForking()
{
$db = \Scalr::getDb();
// Get pid of running daemon
$pid = @file_get_contents(CACHEPATH . "/" . __CLASS__ . ".Daemon.pid");
$this->Logger->info("Current daemon process PID: {$pid}");
// Check is daemon already running or not
if ($pid) {
$Shell = new Scalr_System_Shell();
// Set terminal width
putenv("COLUMNS=400");
// Execute command
$ps = $Shell->queryRaw("ps ax -o pid,ppid,command | grep ' 1' | grep {$pid} | grep -v 'ps x' | grep DBQueueEvent");
$this->Logger->info("Shell->queryRaw(): {$ps}");
if ($ps) {
// daemon already running
$this->Logger->info("Daemon running. All ok!");
return true;
}
}
$rows = $db->Execute("SELECT * FROM events WHERE ishandled = '0' ORDER BY id ASC");
while ($dbevent = $rows->FetchRow()) {
try {
//TODO: Initialize Event classes
$Event = unserialize($dbevent['event_object']);
if ($Event) {
Logger::getLogger(__CLASS__)->info(sprintf(_("Fire event %s for farm: %s"), $Event->GetName(), $Event->GetFarmID()));
// Fire event
Scalr::FireDeferredEvent($Event);
}
//$db->Execute("UPDATE events SET ishandled='1', event_object = '' WHERE id=?", array($dbevent['id']));
$db->Execute("UPDATE events SET ishandled='1' WHERE id=?", array($dbevent['id']));
} catch (Exception $e) {
Logger::getLogger(__CLASS__)->fatal(sprintf(_("Cannot fire deferred event: %s"), $e->getMessage()));
}
}
}