Added master script crash timeout

This commit is contained in:
Jeroen De Meerleer 2018-09-21 15:13:33 +02:00
parent 74324914c2
commit e3230de8c2
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 4 additions and 2 deletions

View File

@ -41,6 +41,7 @@ INSERT INTO `config` (`conf`, `category`, `type`, `label`, `description`, `value
('dbclean.enabled', 'Database Cleanup', 'text', 'Enabled', 'Database cleanup enabled? (true: yes; false: no)', 'false'),
('dbclean.lastrun', 'Database Cleanup', 'hidden', 'Last run', 'Last run of database cleanup', UNIX_TIMESTAMP()),
('jobs.reboottime', 'Jobs', 'number(0,30)', 'Reboot delay', 'The amount of delay in minutes between scheduling a reboot and the actual reboot', '5');
('master.crashtimeout', 'Master script', 'number()', 'Master script crash timeout', 'The amount of time in seconds after we can assume the master script is crashed', '3600');
-- --------------------------------------------------------

View File

@ -26,11 +26,12 @@
require_once "include/initialize.inc.php";
if(file_exists('/tmp/webcron.lock'))
if(file_exists('/tmp/webcron.lock') && file_get_contents('/tmp/webcron.lock') + 0 < time() - get_configvalue('master.crashtimeout'))
{
die('Script is already running');
}
touch('/tmp/webcron.lock');
unlink('/tmp/webcron.lock');
file_put_contents('/tmp/webcron.lock', time());
/**
* Reboot finalize