public function testWait()
 {
     $this->process_thread->start();
     $this->process_thread->wait();
     $this->assertEquals(0, $this->process_thread->exitCode());
     $this->assertEquals(0, $this->process_thread->errno());
     $this->process_runable->start();
     $this->process_runable->wait();
     $this->assertEquals(0, $this->process_runable->exitCode());
     $this->assertEquals(0, $this->process_runable->errno());
     $this->process_callback->start();
     $this->process_callback->wait();
     $this->assertEquals(0, $this->process_callback->exitCode());
     $this->assertEquals(0, $this->process_callback->errno());
 }
Beispiel #2
0
 /**
  * @param ReaderInterface $reader
  * @param FilterInterface $filter
  * @param NotificationInterface $notify
  */
 public function __construct(ReaderInterface $reader, FilterInterface $filter, NotificationInterface $notify)
 {
     parent::__construct();
     $this->reader = $reader;
     $this->filter = $filter;
     $this->notify = $notify;
     $this->registerSignalHandler(SIGTERM, array($this, 'signalHandler'));
 }
Beispiel #3
0
 /**
  * @param string $name
  * @param string $cmd
  * @param string $time
  * @param string|null $out
  * @param string|null $user
  * @param string|null $group
  * @param string|null $comment
  */
 public function __construct($name, $cmd, $time, $out = null, $user = null, $group = null, $comment = null)
 {
     parent::__construct();
     $this->name = $name;
     $this->cmd = $cmd;
     $this->time = $time;
     $this->out = $out;
     $this->user = $user;
     $this->group = $group;
     $this->comment = $comment;
 }
 public function testWait()
 {
     $this->process_thread = new MyThread();
     $this->process_runnable = new \Jenner\SimpleFork\Process(new MyRunnable());
     $this->process_callback = new \Jenner\SimpleFork\Process(function () {
         for ($i = 0; $i < 3; $i++) {
             //                echo "callback pid:" . getmypid() . PHP_EOL;
         }
     });
     $this->process_thread->start();
     $this->process_thread->wait();
     $this->assertEquals(0, $this->process_thread->errno());
     $this->assertEquals($this->process_thread->errno(), 0);
     $this->assertEquals($this->process_thread->errmsg(), 'Success');
     $this->assertEquals($this->process_thread->isRunning(), false);
     $this->process_runnable->start();
     $this->process_runnable->wait();
     $this->assertEquals(0, $this->process_runnable->errno());
     $this->process_callback->start();
     $this->process_callback->wait();
     $this->assertEquals(0, $this->process_callback->errno());
 }
Beispiel #5
0
 /**
  * @param string $name
  * @param string $cmd
  * @param string $time
  * @param LoggerInterface $out
  * @param LoggerInterface $err
  * @param string|null $user
  * @param string|null $group
  * @param string|null $comment
  */
 public function __construct($name, $cmd, $time, LoggerInterface $out = null, LoggerInterface $err = null, $user = null, $group = null, $comment = null)
 {
     parent::__construct();
     $this->name = $name;
     $this->cmd = $cmd;
     $this->time = $time;
     $this->user = $user;
     $this->group = $group;
     $this->comment = $comment;
     if (is_null($out)) {
         $this->out = new Logger(Crontab::NAME);
         $this->out->pushHandler(new NullHandler());
     } else {
         $this->out = $out;
     }
     if (is_null($err)) {
         $this->err = new Logger(Crontab::NAME);
         $this->err->pushHandler(new NullHandler());
     } else {
         $this->err = $err;
     }
 }