Browse Source

RpcWorker conf

walkor 12 years ago
parent
commit
54ab74fe2b

+ 10 - 1
applications/Rpc/Clients/RpcClient.php

@@ -20,7 +20,7 @@ class RpcClient
     
     protected $serviceName = '';
     
-    protected static function config($address_array = array())
+    public static function config($address_array = array())
     {
         if(!empty($address_array))
         {
@@ -152,5 +152,14 @@ class RpcProtocol
     {
         return json_decode(trim($bin_data), true);
     }
+}
 
+if(false)
+{
+    $address_array = array(
+            'tcp://127.0.0.1:2015',
+            'tcp://127.0.0.1:2015'
+            );
+    RpcClient::config($address_array);
+    var_export(RpcClient::instance('User')->getInfoByUid(123));
 }

+ 1 - 1
applications/Rpc/Services/User.php

@@ -5,7 +5,7 @@
  */
 class User
 {
-   public static function getInfo($uid)
+   public static function getInfoByUid($uid)
    {
        return array(
                'uid'    => $uid,

+ 13 - 0
conf/conf.d/RpcWorker.conf

@@ -0,0 +1,13 @@
+;Rpc服务
+;监听的端口
+listen = tcp://0.0.0.0:2015
+;这里设置成短连接
+persistent_connection = 0
+;启动多少worker进程
+start_workers=1
+;接收多少请求后退出
+max_requests=1000
+;以哪个用户运行该worker进程
+user=www-data
+;socket有数据可读的时候预读长度,一般设置为应用层协议包头的长度
+preread_length=84000