Called when the worker is ready to go.
@return void
177786
public function onReady()
    {
        $appInstance = $this; // a reference to this application instance for ExampleWebSocketRoute
        \PHPDaemon\Servers\WebSocket\Pool::getInstance()->addRoute('ExamplePubSub',
            function ($client) use ($appInstance) {
                return new ExamplePubSubWebSocketRoute($client, $appInstance);
            });
        $this->sql = \PHPDaemon\Clients\MySQL\Pool::getInstance();
        $this->pubsub = new \PHPDaemon\PubSub\PubSub();
        $this->pubsub->addEvent('usersNum', \PHPDaemon\PubSub\PubSubEvent::init()
            ->onActivation(function ($pubsub) use ($appInstance) {
                \PHPDaemon\Core\Daemon::log('onActivation');
                if (isset($pubsub->event)) {
                    \PHPDaemon\Core\Timer::setTimeout($pubsub->event, 0);
                    return;
                }
                $pubsub->event = setTimeout(function ($timer) use ($pubsub, $appInstance) {
                    $appInstance->sql->getConnection(function ($sql) use ($pubsub) {
                        if (!$sql->connected) {
                            return;
                        }
                        $sql->query('SELECT COUNT(*) `num` FROM `dle_users`', function ($sql, $success) use ($pubsub) {
                            $pubsub->pub(sizeof($sql->resultRows) ? $sql->resultRows[0]['num'] : 'null');
                        });
                    });
                    $timer->timeout(5e6); // 5 seconds
                }, 0);
            })
            ->onDeactivation(function ($pubsub) {
                if (isset($pubsub->event)) {
                    \PHPDaemon\Core\Timer::cancelTimeout($pubsub->event);
                }
            })
        );
    }
378384
public function doneWorking()
	{
		$this->currentJob = null;
		Resque_Stat::incr('processed');
		Resque_Stat::incr('processed:' . (string)$this);
		Resque::redis()->del('worker:' . (string)$this);
	}
768771
public function onBeforeWrite()
    {
        $owner = $this->owner;
        $owner->IDCustomValue = Convert::raw2url($owner->IDCustomValue);
    }
1075437
protected function onInit()
    {
        $this->limit = Utility::get($this->params, 0, 10);
        $this->offset = Utility::get($this->params, 1, 0);
    }
390020
public function onConfigUpdated()
    {
        if (Daemon::$process instanceof Thread\Worker) {
            if ($this->config === null) {
                $this->disable();
            } else {
                $this->enable();
            }
        }
        if ($defaults = $this->getConfigDefaults()) {
            $this->config->imposeDefault($defaults);
        }
        $this->applyConfig();
    }
1164521
public function onShutdown()
    {
        $error = error_get_last();
        if ($error === null) {
            return;
        }
        if (($error['type'] & error_reporting()) === 0) {
            return;
        }
        if ($this->lastError !== null &&
            $error['message'] === $this->lastError['message'] &&
            $error['file'] === $this->lastError['file'] &&
            $error['line'] === $this->lastError['line']) {
            return;
        }
        $trace = [[
            'file' => $error['file'],
            'line' => $error['line'],
        ]];
        $exc = new Errors\Fatal($error['message'], $trace);
        $this->notifier->notify($exc);
    }
1101193
public function onReady()
    {

        // Adding listener
        // ComplexJob - STATE_WAITING
        $job = new \PHPDaemon\Core\ComplexJob(function ($job) {
            // ComplexJob - STATE_DONE
            /*array (
              'bar' =>
              array (
                    'job' => 'bar',
                    'success' => false,
                    'line' => 63,
              ),
              'foo' =>
              array (
                    'job' => 'foo',
                    'success' => true,
                    'line' => 84,
                    'arg' =>
                    array (
                      'param' => 'value',
                    ),
              ),
              'baz' =>
              array (
                    'job' => 'baz',
                    'success' => false,
                    'line' => 94,
              ),
            )*/
            \PHPDaemon\Core\Daemon::log($job->results);
        });

        // Adding listener
        // ComplexJob - STATE_WAITING
        $job->addListener(function ($job) {
            // ComplexJob - STATE_DONE
        });

        // Adding async job foo
        $job('foo', $this->foo(['param' => 'value']));

        // Adding with 1 sec delay
        \PHPDaemon\Core\Timer::add(function ($event) use ($job) {

            // Adding async job bar
            $job('bar', function ($jobname, $job) {
                \PHPDaemon\Core\Timer::add(function ($event) use ($jobname, $job) {
                    // Job done
                    $job->setResult($jobname, ['job' => 'bar', 'success' => false, 'line' => __LINE__]);
                    $event->finish();
                }, 1e3 * 50);
            });

            // Adding async job baz. Equal $job('baz', $this->baz());
            $job->addJob('baz', $this->baz());

            // Run jobs. All listeners will be called when the jobs done
            // ComplexJob - STATE_RUNNING
            $job();

            $event->finish();
        }, 1e6 * 1);
    }
235296
public function onConfigUpdated()
    {
        if ($this->client) {
            $this->client->config = $this->config;
            $this->client->onConfigUpdated();
        }
    }
1095702
public function onReady()
    {
        $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();

        /*$this->redis->eval("return {'a','b','c', {'d','e','f', {'g','h','i'}} }",0, function($redis) {
            Daemon::log(Debug::dump($redis->result));
        });*/

        $this->redis->subscribe('te3st', function ($redis) {
            Daemon::log(Debug::dump($redis->result));
        });
        $this->redis->psubscribe('test*', function ($redis) {
            Daemon::log(Debug::dump($redis->result));

        });
    }
1254325
public function onReady()
    {
        $this->ptr =& $this->result;
        if (!isset($this->password)) {
            if (isset($this->pool->config->select->value)) {
                $this->select($this->pool->config->select->value);
            }
            parent::onReady();
            $this->setWatermark(null, $this->pool->maxAllowedPacket + 2);
            return;
        }
        $this->sendCommand('AUTH', [$this->password], function () {
            if ($this->result !== 'OK') {
                $this->log('Auth. error: ' . json_encode($this->result));
                $this->finish();
            }
            if (isset($this->pool->config->select->value)) {
                $this->select($this->pool->config->select->value);
            }
            parent::onReady();
            $this->setWatermark(null, $this->pool->maxAllowedPacket + 2);
        });
    }
950988
public function onReady()
    {
        $conn = $this;
        $this->keepaliveTimer = setTimeout(function ($timer) use ($conn) {
            $conn->ping();
        }, 10e6);
    }
102512
public function onFinish()
    {
        foreach ($this->cursors as $curId => $cur) {
            if ($cur instanceof Cursor) {
                $cur->destroy(true);
            }
        }
        $this->cursors = null;
        $this->requests = null;
        parent::onFinish();
    }
445001
public function execute()
    {
        if ($this->state === self::STATE_WAITING) {
            $this->state = self::STATE_RUNNING;
            foreach ($this->jobs as $name => $cb) {
                $cb($name, $this);
                $this->jobs[$name] = null;
            }
            $this->checkIfAllReady();
        }
    }
1145059
public function proccess()
    {
        foreach ($this->runningJobs as $jobData) {
            $this->isRunning($jobData->job);
        }

        foreach ($this->pendingJobs as $job) {
            $this->start($job);
        }
    }
713964
public function onReady()
    {
        $this->connected = true;
        if ($this->onConnected) {
            $this->onConnected->executeAll($this);
            $this->onConnected = null;
        }
    }
1137117
public function onWorkerStart()
    {
        if (empty($this->serverRoot)) {
            Worker::safeEcho(new \Exception('server root not set, please use WebServer::addRoot($domain, $root_path) to set server root path'));
            exit(250);
        }

        // Init mimeMap.
        $this->initMimeTypeMap();

        // Try to emit onWorkerStart callback.
        if ($this->_onWorkerStart) {
            try {
                call_user_func($this->_onWorkerStart, $this);
            } catch (\Exception $e) {
                self::log($e);
                exit(250);
            } catch (\Error $e) {
                self::log($e);
                exit(250);
            }
        }
    }
1375033
public function complete()
    {
        $this->stopped();

        $this->setStatus(Job::STATUS_COMPLETE);

        $this->redis->zadd(Queue::redisKey($this->queue, 'processed'), time(), $this->payload);
        Stats::incr('processed', 1);
        Stats::incr('processed', 1, Queue::redisKey($this->queue, 'stats'));

        Event::fire(Event::JOB_COMPLETE, $this);
    }