<?php declare (ticks=1); require_once __DIR__ . '/../vendor/autoload.php'; use Arara\Process\Action\Daemon; use Arara\Process\Child; use Arara\Process\Context; use Arara\Process\Control; $daemon = new Daemon(function (Daemon $daemon, Control $control) { openlog($daemon->getOption('name'), LOG_PID | LOG_PERROR, LOG_LOCAL0); $control->flush(60); }); $daemon->bind(Daemon::EVENT_SUCCESS, function () { syslog(LOG_INFO, 'Daemon was successfully finished'); }); $daemon->bind(Daemon::EVENT_ERROR | Daemon::EVENT_FAILURE, function (Context $context) { syslog(LOG_ERR, $context->exception->getMessage()); }); $daemon->bind(Daemon::EVENT_FINISH, function () { closelog(); }); $daemon->setOption('lock_dir', __DIR__); $control = new Control(); $process = new Child($daemon, $control); try { $args = $_SERVER['argv']; $script = array_shift($args); $usageMessage = sprintf('php %s {start|stop|status}', $script); if (empty($args)) { throw new DomainException($usageMessage); }
/** * @expectedException Arara\Process\Exception\LogicException * @expectedExceptionMessage Pidfile is not defined */ public function testShouldThrowsAnExceptionWhenPidfileIsNotDefinedOnStartEvent() { $context = new Context(); $control = new Control(); $daemon = new Daemon(function () { }); $daemon->trigger(Daemon::EVENT_START, $control, $context); }