12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- define('BASE_ROOT_PATH',str_replace('\\','/',dirname(__FILE__)));
- require_once (BASE_ROOT_PATH . '/fooder.php');
- require_once (BASE_ROOT_PATH . '/helper/search/server.php');
- require_once (BASE_ROOT_PATH . '/helper/search/processor.php');
- require_once (BASE_ROOT_PATH . '/helper/search/event_handler.php');
- require_once(BASE_ROOT_PATH . '/helper/search/util.php');
- require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/search/searcher.php');
- require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
- function search_work($sockfd)
- {
- echo "start searcher";
- Base::run_util();
- search\searcher::instance();
- search\CentraHelper::instance()->init(new search\processor());
- echo "start ending";
- search\CentraHelper::instance()->run_loop($sockfd);
- echo "end run_loop";
- }
- function fork_subprocess($count,$listen_fd)
- {
- if (($child = pcntl_fork()) === 0)
- {
- echo "pid = {$child} count = {$count} " . __LINE__ ."\r\n";
- search_work($listen_fd);
- exit();
- }
- elseif($child === -1)
- {
- echo "pid = {$child} count = {$count} " . __LINE__ ."\r\n";
- die('could not fork');
- }
- else
- {
- echo "pid = {$child} count = {$count} " . __LINE__ ."\r\n";
- $ret = pcntl_waitpid($child,$status,WNOHANG);
- if($ret == 0) {
- echo "spawn-fcgi: successful ret == 0 PID: {$child}\n" ;
- }
- elseif($ret == -1) {
- echo "spawn-fcgi: ret == 0 PID: {$child}\n" ;
- }
- else {
- echo "spawn-fcgi: ret == 0 child exited PID: {$child}.\n";
- }
- }
- }
- function remote_addr()
- {
- global $config;
- $host = $config['searcher']['host'];
- $port = $config['searcher']['port'];
- return "{$host}:{$port}";
- }
- $listen_fd = stream_socket_server (remote_addr(), $errno, $errstr);
- $addr = remote_addr();
- echo "remote addr = {$addr} fd={$listen_fd}";
- search_work($listen_fd);
- //$count = 1;
- //while ($count-- > 0) {
- // fork_subprocess($count,$listen_fd);
- //}
|