public function __construct($ip = "0.0.0.0", $port = 9569, $config = array())
{
//record ip:port
$this->_ip = $ip;
$this->_port = $port;
//create server object
$this->_server = new \swoole_server($ip, $port, \SWOOLE_PROCESS, \SWOOLE_SOCK_UDP);
//set config
$this->_server->set(array('open_length_check' => 1, 'dispatch_mode' => 3, 'package_length_type' => 'N', 'package_length_offset' => 0, 'package_body_offset' => 4, 'package_max_length' => 1024 * 1024 * 2, 'buffer_output_size' => 1024 * 1024 * 3, 'pipe_buffer_size' => 1024 * 1024 * 32, 'open_tcp_nodelay' => 1, 'heartbeat_check_interval' => 5, 'heartbeat_idle_time' => 10, 'reactor_num' => 1, 'worker_num' => 2, 'task_worker_num' => 0, 'max_request' => 0, 'task_max_request' => 4000, 'backlog' => 2000, 'log_file' => '/tmp/sw_monitor.log', 'task_tmpdir' => '/tmp/swmonitor/', 'daemonize' => 0));
//register the event
$this->_server->on('Packet', array($this, 'onPacket'));
echo "Start Init Server udp://" . $ip . ":" . $port . PHP_EOL;
//store the list of redis
$this->_config["redis"] = $config["discovery"];
//store the avaliable node list to this config file
$this->_config["export_path"] = $config["config"];
//log monitor path
$this->_config["log_path"] = $config["log"];
$this->discovery($this->_config["redis"]);
}