/** * Delete all status file after exit() called * */ public final function shutdown($force = false) { if ($this->parent_pid == posix_getpid()) { $this->logger->info("Shutdown in progress, cleaning environment"); Lock::release(); Status::release(); Queue::release(); Planner::release(); } if ($force === true) { $this->logger->info("Shutdown in progress, cleaning environment"); Status::release(); Queue::release(); Planner::release(); } }
public function testRelease() { $result = \Comodojo\Extender\Queue::release(); $this->assertTrue($result); }
/** * Execute job(s) in current queue * * @return array An array of completed processes */ public final function run() { // if jobs > concurrent jobs, create the queue if ($this->multithread and defined("EXTENDER_MAX_CHILDS") and sizeof($this->jobs) > EXTENDER_MAX_CHILDS and EXTENDER_MAX_CHILDS != 0) { $this->queued_processes = sizeof($this->jobs); // split jobs in chunks $this->queued_chunks = array_chunk($this->jobs, EXTENDER_MAX_CHILDS, true); // exec chunks, one at time foreach ($this->queued_chunks as $chunk) { $this->queued_processes = $this->queued_processes - sizeof($chunk); Queue::dump(sizeof($chunk), $this->queued_processes); $this->forker($chunk); if ($this->multithread) { $this->logger->info("Extender forked " . sizeof($this->forked_processes) . " process(es) in the running queue", $this->forked_processes); } $this->catcher(); $this->forked_processes = array(); } } else { Queue::dump(sizeof($this->jobs), 0); $this->forker($this->jobs); if ($this->multithread) { $this->logger->info("Extender forked " . sizeof($this->forked_processes) . " process(es) in the running queue", $this->forked_processes); } $this->catcher(); } // Dump the end queue status Queue::dump(sizeof($this->running_processes), $this->queued_processes); return $this->completed_processes; }