public function restart()
    {
        if (count($this->tasks) == 0)
            throw new \Exception("There are no tasks defined - can not restart");

        $this->stop();

        do {
            sleep(1);
        } while ($this->getPid() !== false);

        $this->start();
    }