usr bin env php php define BASEPATH define APPPATH require_once librar

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env php
<?php
define('BASEPATH', '../../');
define('APPPATH', '../');
require_once("../libraries/DoctrineORM.php");
require_once("SystemDaemon.php");
new DoctrineORM;
// hit queue to autload Queue before the daemon started
// Queue::receiveEvents(date('1900-01-01 00:00:00'));
class NaiveConsumer extends SystemDaemon
{
public function process()
{
$timestamp = date('Y-m-d H:i:s', time());
$events = Queue::receiveEvents($timestamp);
$this->log->debug("Receive events (%d)", $events->count());
foreach ($events as $event)
{
$this->log->debug("Got event %d -- %s (should fire at %s)",
$event['EventID'], $event['EventName'],
$event['ShouldFireAt']);
// do something with event
// and mark it's done
Queue::markEventDone($event['EventID']);
}
}
}
$consumer = new NaiveConsumer($argc, $argv);
?>