/** * @keepalive */ public function startLocal() { $this->_clockworkManager = new CM_Clockwork_Manager(); $storage = new CM_Clockwork_Storage_FileSystem('app-maintenance-local'); $storage->setServiceManager(CM_Service_Manager::getInstance()); $this->_clockworkManager->setStorage($storage); $this->_registerCallbacksLocal(); $this->_clockworkManager->start(); }
/** * @keepalive */ public function startMaintenance() { $clockwork = new CM_Clockwork_Manager(); $storage = new CM_Clockwork_Storage_FileSystem('search-maintenance'); $storage->setServiceManager(CM_Service_Manager::getInstance()); $clockwork->setStorage($storage); $clockwork->registerCallback('search-index-update', '1 minute', array($this, 'update')); $clockwork->registerCallback('search-index-optimize', '1 hour', array($this, 'optimize')); $clockwork->start(); }
public function testStartTerminatable() { $process = CM_Process::getInstance(); $forkHandler = $process->fork(function () { $clockworkManager = new CM_Clockwork_Manager(); $clockworkManager->start(); }); usleep(1000000 * 0.1); $process->listenForChildren(); $this->assertSame(true, $process->isRunning($forkHandler->getPid())); posix_kill($forkHandler->getPid(), SIGTERM); usleep(1000000 * 0.1); $process->listenForChildren(); $this->assertSame(false, $process->isRunning($forkHandler->getPid())); }