forked from kakserpom/phpdaemon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpd
executable file
·78 lines (66 loc) · 1.93 KB
/
phpd
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/php -q
<?php
/**************************************************************************/
/* phpDaemon
/* Web: http://github.com/kakserpom/phpdaemon
/* ===========================
/* @author kak.serpom.po.yaitsam@gmail.com
/* @description Bootstrap init script.
/**************************************************************************/
@ob_end_clean(); // clear shebang
error_reporting(E_ALL);
foreach (array('/usr/share/phpdaemon', dirname(dirname(__FILE__))) as $d) {
if (@chdir($d)) {
break;
}
}
ini_set('include_path', get_include_path()
. ':' . dirname(dirname(__FILE__))
. ':' . dirname(dirname(__FILE__)).'/conf'
. ':/usr/share/phpdaemon:/etc/phpdaemon'
);
spl_autoload_register(function($classname) {
$parts = explode('\\', $classname);
if (sizeof($parts) > 1 && ('PHPDaemon' == $parts[0])) {
// namespaces support (remove first "PHPDaemon\" part)
array_shift($parts);
}
$pathes = array('lib/' . implode('/', $parts) . '.php', 'lib/' . implode('/', $parts));
foreach ($pathes as $path) {
if (file_exists($path)) {
require $path;
return;
}
}
if (class_exists('Daemon', false) && isset(Daemon::$config->autoload->value)) {
$files = glob(sprintf(Daemon::$config->autoload->value, str_replace('_', DIRECTORY_SEPARATOR, $classname)), GLOB_BRACE);
if (isset($files[0])) {
require $files[0];
return;
}
}
if (class_exists('Daemon', false) && isset(Daemon::$config->appfilepath->value)) {
$files = glob($g = sprintf(Daemon::$config->appfilepath->value, str_replace('_', DIRECTORY_SEPARATOR, $classname)), GLOB_BRACE);
if (isset($files[0])) {
require $files[0];
return;
}
}
});
class_exists('Debug');
require 'lib/BinarySubstr.php';
$e = null;
execute:
try {
if ($e) {
$thread = $e->thread;
$e = null;
$thread->run();
$thread->shutdown();
}
else {
Daemon_Bootstrap::init(isset($configFile) ? $configFile : null);
}
} catch (ClearStackException $e) {
goto execute;
}