public function doWork()
    {
        /**
         * Installing signal handlers
         */
        $this->cliHelper->writeTimeLine('Setting up signal handlers...');
        declare(ticks = 1);
    
        pcntl_signal(SIGTERM, array($this, 'shutdownProcesses'));
        pcntl_signal(SIGINT, array($this, 'shutdownProcesses'));
        pcntl_signal(SIG_IGN, array($this, 'shutdownProcesses'));
        pcntl_signal(SIGHUP, array($this, 'shutdownProcesses'));
    
        pcntl_signal(SIGCHLD, array($this, 'startCrashedProcess'));
    
        /**
         * Starting processes
         */
        $this->cliHelper->writeTimeLine('Starting processes...');
        foreach ($this->tasks as $task) {
            for ($i = 0; $i < $task->getInstances(); $i++) {
                $this->startProcess($task);
            }
        }
    
        /**
         * Monitoring processes and restart after the specified time
         */
        $this->cliHelper->writeTimeLine('Monitoring processes...');
        while (true) {
            foreach ($this->processes as $process) {
                /**
                 * If runtime for one process is reached, kill him and restart
                 */
                if ($process->getRestartTime() < time()) {
                    $this->restartProcess($process);
                }
            }
    
            sleep(1);
        }
    }