vyants/yii2-daemon

Stop the daemon

wolfDiesel opened this issue · 9 comments

How to stop the daemon???

kill -15 {PID}
does nothing. Watcher just restarts

The best way - get array with daemons list from external storage (database or .ini file, for example). If you do that, you can just set 'enabled' property to false in database and Watcher will kill daemon automaticaly.

/**
  * @return array
  */
  protected function defineJobs()
   {
      sleep($this->sleep);
      //Get this array from external source
      $daemons = [
          //this daemon is always up
          ['className' => 'OneDaemonController', 'enabled' => true],
          //this daemon is always down
          ['className' => 'AnotherDaemonController', 'enabled' => false]
      ];
      return $daemons;
   }

You didnt understand.
Stop the Daemon That is already running,.

You can't stop daemon manually if watcher is running.
You must disable daemon in watcher.

Okay, how do i stop the watcher? Programmatically?

kstkn commented

Well, Watcher at least should stop all other daemons when killed.

+1

So what is the solution?

Not the best solution is terminate all processes daemon and watchers with ``kill`

kill -9 $(pgrep -f "DaemonController")

Best solution is create own init.d script and use commands like sudo service yii-daemon restart
https://github.com/jasonblewis/sample-service-script