当前位置: 首页>>代码示例>>PHP>>正文


PHP Scalr::FireDeferredEvent方法代码示例

本文整理汇总了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;
 }
开发者ID:recipe,项目名称:scalr,代码行数:20,代码来源:class.FireDeferredEventTask.php

示例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()));
         }
     }
 }
开发者ID:recipe,项目名称:scalr,代码行数:37,代码来源:class.DBQueueEventProcess.php


注:本文中的Scalr::FireDeferredEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。