为什么同样的代码,在本地可以joinGroup而到了服务器上就不能joinGroup呢?

jbking

没有任何报错!
为什么同样的代码,在本地可以joinGroup而到了服务器上就不能joinGroup呢?

除了使用 php start status后,本地多一个

25774   1.75M   text://127.0.0.1:13001    TimeWorker    0           0              0         0   

服务器上没有之外,都是一样的。
不知道为什么服务器上没有呢?或者是有什么其他原因导致的呢?

在本地机器MAC的

Workerman status 
---------------------------------------GLOBAL STATUS--------------------------------------------
Workerman version:3.3.2          PHP version:5.5.34
start time:2016-08-26 17:30:36   run 0 days 0 hours   
load average: 2.84814453125, 2.56396484375, 2.361328125event-loop:select
6 workers       15 processes
worker_name   exit_status     exit_count
TradeBusiness 0                0
Gateway       0                0
PushWorker    0                0
Register      0                0
TaskWorker    0                0
TimeWorker    0                0
---------------------------------------PROCESS STATUS-------------------------------------------
pid memory  listening                 worker_name   connections total_request send_fail throw_exception
25761   1.25M   websocket://0.0.0.0:13016 Gateway       3           295            0         0              
25760   1.5M    none                      TradeBusiness 3           3              0         0              
25762   1.25M   text://127.0.0.1:13002    PushWorker    2           294            0         0              
25763   1.25M   text://0.0.0.0:1236       Register      3           297            0         0              
25765   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25764   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25766   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25767   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25768   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25769   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25770   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25771   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25772   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25773   1M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
25774   1.75M   text://127.0.0.1:13001    TimeWorker    0           0              0         0     

在服务器上的

Workerman status 
---------------------------------------GLOBAL STATUS--------------------------------------------
Workerman version:3.3.2          PHP version:5.3.29
start time:2016-08-26 17:43:22   run 0 days 0 hours   
load average: 0.02, 0.02, 0.05   event-loop:select
6 workers       15 processes
worker_name   exit_status     exit_count
TradeBusiness 0                0
Gateway       0                0
PushWorker    0                0
Register      0                0
TaskWorker    0                0
TimeWorker    0                0
---------------------------------------PROCESS STATUS-------------------------------------------
pid     memory  listening                 worker_name   connections total_request send_fail throw_exception
7755    2.5M    none                      TradeBusiness 3           2              0         0              
7756    2.25M   websocket://0.0.0.0:13016 Gateway       2           1              0         0              
7757    2.25M   text://127.0.0.1:13002    PushWorker    2           1              0         0              
7758    2.25M   text://0.0.0.0:1288       Register      3           12             0         0              
7759    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
7760    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
7761    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
7762    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
7763    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
7764    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
7765    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
7766    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
7767    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0              
7768    2M      text://127.0.0.1:13000    TaskWorker    0           0              0         0
8697 8 0
8个回答

walkor

从你给的信息中看不出来问题

  • 暂无评论
jbking

@walkor 刚才,我也真不知道该给什么数据,代码一模一样,
刚刚,我针对业务定时器做了些跟踪:

ctrl C 后出现 worker exit with status 9
于是我跟踪了Timer的代码执行时间,发现 Gateway::getClientCountByGroup 执行时间很长
这个问题只会在,我们的服务器上出现,在本机则没有这个问题
我们的服务器上,在另外一个目录下面还跑着一个Gateway的应用

定时器调用:

$worker->onWorkerStart = function($worker) {

    //定时器
    foreach(Tag::$walletType as $k=>$v){
        Timer::add(1, array('\Program\Market', 'sendNewTenthOrder'), array($k));
    }
}

执行代码是:
这个函数会被1秒钟执行9次,是完整的业务逻辑里面这个函数会查询数据库

    public static function sendNewTenthOrder($wallet){
        echo Tag::$walletType;
        $start = time();
        var_dump(Gateway::getClientCountByGroup(Tag::$walletType));
        echo "Gateway::getClientCountByGroup 执行了".(time()-$start)."秒";
     }

执行结果是:

Gateway::getClientCountByGroup 执行了1秒woodint(0)
Gateway::getClientCountByGroup 执行了1秒stoneint(0)
Gateway::getClientCountByGroup 执行了1秒goldint(0)
Gateway::getClientCountByGroup 执行了1秒iron^CWorkerman Stopping ...
int(0)
Gateway::getClientCountByGroup 执行了2秒horseworker exit with status 9
  • 暂无评论
jbking

@walkor 原因找到了,两个应用的注册服务器的地址冲突了,注册到另外的注册服务器上了
但是,为什么自定义了注册中心地址后,实际上还是用的Lib下的Gateway下的这个注册中心地址呢?

 /**
     * 注册中心地址
     *
     * @var string
     */
    public static $registerAddress = '127.0.0.1:1236';
  • 暂无评论
walkor

默认值,实际上不一定是这个值

  • 暂无评论
jbking

@walkor 那使用中,是直接在start_business中,使用 Gateway::$registerAddress来赋值使用自定义的注册服务器地址吗?

  • 暂无评论
walkor

在这句设置的,
$businessworker->registerAddress='.....';
设置了这句之后会自动设置Lib/Gateway::$registerAddress

  • 暂无评论
jbking

@walkor 奇怪了,我是这样设置的,但是不行的。。。。。

我定义了常量REGISTER_PROTOCOLS作为注册服务器的地址和端口,然后在:start_register,start_gateway和start_business里面统一用这个常量的。

注册服务起来后地址和端口与REGISTER_PROTOCOLS一致
但是gateway和business却注册到Lib/Gateway::$registerAddress的缺省值上了

比如在start_business里:
$business_trade_worker->registerAddress = REGISTER_PROTOCOLS;

//REGISTER_PROTOCOLS为0.0.0.0:1288

或者,我还需要检查那个部分的代码?

  • 暂无评论
walkor

不清楚了,只运行单个实例看看,多打打日志吧。

  • 暂无评论
年代过于久远,无法发表回答
🔝