-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdaemon-example.php
More file actions
39 lines (32 loc) · 857 Bytes
/
Copy pathdaemon-example.php
File metadata and controls
39 lines (32 loc) · 857 Bytes
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
#!/usr/bin/php
<?php
/* daemon sample */
require "class.daemon.php";
function childJob(&$daemon) {
$daemon->childObject->stack();
}
function childStart(&$daemon) {
$dummy=new dummy();
$dummy->setuniq();
echo "Starting new child with: {$dummy->uniqid}\n";
$daemon->childObject=$dummy;
return TRUE;
}
function childDying(&$daemon,$pid) {
echo "Child with: {$daemon->currentObjects[$pid]->uniqid} terminating\n";
}
class dummy {
public $uniqid=NULL;
function setuniq() {
$this->uniqid=uniqid();
}
function stack() {
while(1) sleep(2000);
}
}
$job=new Daemon();
$job->procName='phpdaemon';
$job->bind('onLauncher','childStart');
$job->bind('onLaunchJob','childJob');
$job->bind('onChildTerminated','childDying');
$job->run();