|
@@ -9,18 +9,12 @@ define('BASE_PATH',BASE_ROOT_PATH . '/rdispatcher');
|
|
|
|
|
|
require_once(BASE_ROOT_PATH . '/global.php');
|
|
|
require_once(BASE_ROOT_PATH . '/fooder.php');
|
|
|
-require_once(BASE_ROOT_PATH . '/fooder.php');
|
|
|
-
|
|
|
require_once(BASE_HELPER_PATH . '/event_looper.php');
|
|
|
require_once(BASE_HELPER_PATH . '/queue/rdispatcher.php');
|
|
|
require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
|
|
|
-require_once(BASE_HELPER_PATH . '/message/msgstates.php');
|
|
|
-require_once(BASE_HELPER_PATH . '/message/msgutil.php');
|
|
|
-require_once(BASE_HELPER_PATH . '/message/subscriber.php');
|
|
|
-
|
|
|
+require_once(BASE_HELPER_PATH . '/algorithm.php');
|
|
|
require_once(BASE_PATH . '/processor.php');
|
|
|
require_once(BASE_PATH . '/proxy.php');
|
|
|
-require_once(BASE_PATH . '/yzpolicy.php');
|
|
|
|
|
|
//这个可以
|
|
|
//Co::set(['hook_flags' => SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_TCP ^ SWOOLE_HOOK_UDP ^
|
|
@@ -45,49 +39,37 @@ Co::set(['hook_flags' => SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_TCP]);
|
|
|
if (empty($_SERVER['argv'][1])) exit('parameter error');
|
|
|
$count = intval($_SERVER['argv'][1]);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
function all_channels() {
|
|
|
return ['refill'];
|
|
|
}
|
|
|
|
|
|
+function handle_error($level, $message, $file, $line)
|
|
|
+{
|
|
|
+ if($level == E_NOTICE) return;
|
|
|
+ $trace = "handle_error: level={$level},msg={$message} file={$file},line={$line}\n";
|
|
|
+ $backtrace = debug_backtrace();
|
|
|
+ foreach ($backtrace as $item) {
|
|
|
+ $trace .= "{$item['file']}\t{$item['line']}\t{$item['function']}\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ Log::record($trace,Log::ERR);
|
|
|
+}
|
|
|
+
|
|
|
function work_proc()
|
|
|
{
|
|
|
Base::run_util();
|
|
|
-
|
|
|
- $trdid = Thread::getCurrentThreadId();
|
|
|
- Log::record("thread id = {$trdid}",Log::INFO);
|
|
|
-//
|
|
|
-// $gMessageStates = new MsgStates();
|
|
|
-// StatesHelper::init();
|
|
|
-// $listener = new message\subscriber($gMessageStates);
|
|
|
-// $listener->start();
|
|
|
-
|
|
|
+ set_error_handler('handle_error');
|
|
|
$looper = new processor();
|
|
|
$looper->run();
|
|
|
}
|
|
|
|
|
|
+//swoole 和 pthreads 冲突
|
|
|
function corun()
|
|
|
{
|
|
|
Log::record("start run process",Log::DEBUG);
|
|
|
Co\run(function() {
|
|
|
work_proc();
|
|
|
});
|
|
|
-
|
|
|
-// $process = new swoole_process(function(swoole_process $process)
|
|
|
-// {
|
|
|
-// try {
|
|
|
-// Log::record("start run process",Log::DEBUG);
|
|
|
-// Co\run(function() {
|
|
|
-// work_proc();
|
|
|
-// });
|
|
|
-// } catch (Exception $ex) {
|
|
|
-// Log::record("",Log::ERR);
|
|
|
-// }
|
|
|
-// });
|
|
|
-//
|
|
|
-// $pid = $process->start();
|
|
|
-// return $pid;
|
|
|
}
|
|
|
|
|
|
event\util::fork_workerex('corun',$count);
|