Added lock file and messages

This commit is contained in:
Andreas Kristiansen
2025-10-19 08:26:27 +02:00
parent 554d171a78
commit f7b6317da2
2 changed files with 43 additions and 7 deletions

View File

@@ -706,12 +706,38 @@ class Update extends CI_Controller {
}
public function update_vucc_grids() {
// set the last run in cron table for the correct cron id
$this->load->model('cron_model');
$this->cron_model->set_last_run($this->router->class . '_' . $this->router->method);
$lockfilename='/tmp/.update_vucc_grids_running';
if (!file_exists($lockfilename)) {
touch($lockfilename);
$this->load->model('Update_model');
$result = $this->Update_model->update_vucc_grids();
unlink($lockfilename);
if($this->session->userdata('user_type') == '99') {
if (substr($result, 0, 4) == 'DONE') {
$this->session->set_flashdata('success', __("VUCC Grid file update complete. Result: ") . "'" . $result . "'");
} else {
$this->session->set_flashdata('error', __("VUCC Grid file update failed. Result: ") . "'" . $result . "'");
}
redirect('debug');
} else {
echo $result;
}
} else {
log_message('debug', 'There is a lockfile for this job. Checking the age...');
$lockfile_time = filemtime($lockfilename);
$tdiff = time() - $lockfile_time;
if ($tdiff > 120) {
unlink($lockfilename);
log_message('debug', 'Deleted lockfile because it was older then 120seconds.');
} else {
log_message('debug', 'Process is currently locked. Further calls are ignored.');
echo 'locked - running';
}
}
$this->load->model('Update_model');
$this->Update_model->update_vucc_grids();
}
}
?>