public function start()
{
$state = $this->getState();
if (in_array($state, [self::STATE_T_START, self::STATE_T_STOP, self::STATE_T_KILL])) {
$processId = $this->getProcessId();
if (!$this->processExists()) {
$this->getLogger()->warning("Daemon is ill can't find process {$processId}, try clean data and continue starting", [__NAMESPACE__]);
$this->cleanData();
// continue start
} else {
$this->getLogger()->info("Daemon can't START, cause state : {$state}, and process exists {$processId}", [__NAMESPACE__]);
return false;
}
}
$this->setProcessId($pid = intval(getmypid()));
$this->setData(self::P_CREATED_TIME, time());
$this->setState(self::STATE_T_START);
try {
$this->mainLoop();
$this->waitManagersDone();
} catch (\Exception $ex) {
$this->getLogger()->warning($ex->getMessage(), [__NAMESPACE__]);
}
$this->cleanData();
return true;
}