Author: Vladimir Yants (vladimir.yants@gmail.com)
Inheritance: extends yii\console\Controller
 /**
  * Prevent double start
  */
 public function init()
 {
     $pid_file = $this->getPidPath();
     if (file_exists($pid_file) && ($pid = file_get_contents($pid_file)) && file_exists("/proc/{$pid}")) {
         $this->halt(self::EXIT_CODE_ERROR, 'Another Watcher is already running.');
     }
     parent::init();
 }
 public function init()
 {
     $pidFile = \Yii::getAlias($this->pidDir) . DIRECTORY_SEPARATOR . $this->shortClassName();
     if (file_exists($pidFile)) {
         $pid = file_get_contents($pidFile);
         exec("ps -p {$pid}", $output);
         if (count($output) > 1) {
             $this->halt(self::EXIT_CODE_ERROR, 'Another Watcher is already running.');
         }
     }
     parent::init();
 }