private function process($job)
{
$this->log->log('Started : ' . $job . ' ' . time() . "\n");
// This has already been processed
if (file_exists($this->config->projects_root . '/out/' . $job . '.json')) {
display("{$job} already exists\n");
return;
}
file_put_contents($this->config->projects_root . '/progress/jobqueue.exakat', json_encode(array('start' => time(), 'job' => $job, 'progress' => 0)));
shell_exec($this->config->php . ' ' . $this->config->executable . ' onepage -f ' . $this->config->projects_root . '/in/' . $job . '.php');
// cleaning
rename($this->config->projects_root . '/projects/onepage/onepage.json', $this->config->projects_root . '/out/' . $job . '.json');
// final progress
$progress = json_decode(file_get_contents($this->config->projects_root . '/progress/jobqueue.exakat'));
$progress->end = time();
file_put_contents($this->config->projects_root . '/progress/jobqueue.exakat', json_encode($progress));
$this->log->log('Finished : ' . $job . ' ' . time() . "\n");
// Clean after self
shell_exec($this->config->php . ' ' . $this->config->executable . ' cleandb');
}