walkor / GatewayWorker

Distributed realtime messaging framework based on workerman.
MIT License
1.01k stars 296 forks source link

Stop GatewayWorker server callback #8

Closed yayaigo2010 closed 8 years ago

yayaigo2010 commented 8 years ago

Is there a server stop callback function in GatewayWorker? because I want to record server shut down time, when restart server, use the shut down time to recalculate the end time of my gameplay event.

Another question,If operating system or web server(nginx) restart, how can I know the server previous shut down time?

walkor commented 8 years ago

Try to add codes like bellow in start_gateway.php

...
$gateway->onWorkerStop = function($gateway)
{
     // record shut down time only in process of zero
     if($gateway->id === 0)
     {
        // record server shut down time
     }
};
...

You can get operating system shut down time by file /var/log/messages.

yayaigo2010 commented 8 years ago

I already add these code below,but when I stop server, it doesn't show "start_gateway.php onWorkerStop" in my log.

$gateway->onWorkerStop = function($gateway) { echo "start_gateway.php onWorkerStop \n"; // record shut down time only in process of zero if($gateway->id === 0) { // record server shut down time echo "start_gateway.php onWorkerStop 2\n"; } };

walkor commented 8 years ago

May be the version you used does not support。 Update to the latest version will work.