public function manage()
 {
     $this->manager = new Manager();
     $this->manager->setProcessManagerDto($this->gearmanDto->getProcessManagerDto());
     //Gearman worker block any signal besides SIGKILL,
     //so its become impossible to correct send SIGTERM and handle it (execute some other actions before termination)
     $this->manager->setSigTermBlockingAgent(true);
     $this->manager->manage();
     $this->manager->getExecutionDto()->setExecutionMessage("PM with id " . $this->gearmanDto->getTaskId() . " going to finish.");
     $this->manager->getExecutionDto()->setTaskId($this->gearmanDto->getTaskId());
     $this->job->sendComplete(serialize($this->manager->getExecutionDto()));
     return null;
 }
 public function initManager(\GearmanJob $job)
 {
     $this->job = $job;
     $this->gearmanDto = unserialize($job->workload());
     $this->processManager = ProcessManagerFactory::getProcessManager($this->gearmanDto->getManagerType());
     $this->processManager->setJob($job);
     $this->processManager->setGearmanDto($this->gearmanDto);
     try {
         $this->processManager->manage();
     } catch (\Exception $e) {
         $errorMessage = "Gearman process manager die with exception: " . $e->getMessage() . "| gearmanDto: " . serialize($this->gearmanDto);
         $this->logger->warning($errorMessage);
         $this->processManager->getExecutionDto()->setErrorMessage($errorMessage);
         die;
     }
     return null;
 }