mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-09-27 05:05:10 -04:00
feat(jobs): add task time warning threshold setting
Introduce a soft, log-only per-task time budget (jobs_task_max_seconds) separate from the existing web request budget (jobs_web_max_seconds), since PHP cannot preempt a running task mid-execution. - Config: add taskMaxSeconds default (30s) to app/Config/Jobs.php - Controller: validate and persist task_max_seconds in Jobs::postSaveSettings - BoundedTaskRunner: accept taskMaxSeconds, measure task runtime via microtime, log a warning when a task exceeds the threshold - JobRunner: read jobs_task_max_seconds from config and pass it to BoundedTaskRunner - Migration: add AddJobsTaskMaxSecondsConfigKey to seed default app_config value - Language: add en strings for label, validation message, and enabled/disabled tooltips - View: add task_max_seconds form field to settings_config.php, wired to same web-mode enable/disable toggle as web_max_seconds - Tests: update JobsControllerTest to cover new field in save/ validation scenarios Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
This commit is contained in:
1 parent
1e42c3b7ef
commit
14b06eea30
8 files changed
+97
-15
No files matched your search
@@ -61,8 +61,9 @@ class JobsControllerTest extends CIUnitTestCase
|
||||
$this->loginAsAdmin();
|
||||
|
||||
$response = $this->post('/jobs/saveSettings', [
|
||||
'mode' => 'bogus',
|
||||
'web_max_seconds' => 5,
|
||||
'mode' => 'bogus',
|
||||
'web_max_seconds' => 5,
|
||||
'task_max_seconds' => 30,
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
@@ -75,8 +76,9 @@ class JobsControllerTest extends CIUnitTestCase
|
||||
$this->loginAsAdmin();
|
||||
|
||||
$response = $this->post('/jobs/saveSettings', [
|
||||
'mode' => 'web',
|
||||
'web_max_seconds' => -5,
|
||||
'mode' => 'web',
|
||||
'web_max_seconds' => -5,
|
||||
'task_max_seconds' => 30,
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
@@ -89,8 +91,9 @@ class JobsControllerTest extends CIUnitTestCase
|
||||
$this->loginAsAdmin();
|
||||
|
||||
$response = $this->post('/jobs/saveSettings', [
|
||||
'mode' => 'manual',
|
||||
'web_max_seconds' => 10,
|
||||
'mode' => 'manual',
|
||||
'web_max_seconds' => 10,
|
||||
'task_max_seconds' => 20,
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
@@ -99,6 +102,7 @@ class JobsControllerTest extends CIUnitTestCase
|
||||
|
||||
$this->seeInDatabase('app_config', ['key' => 'jobs_mode', 'value' => 'manual']);
|
||||
$this->seeInDatabase('app_config', ['key' => 'jobs_web_max_seconds', 'value' => '10']);
|
||||
$this->seeInDatabase('app_config', ['key' => 'jobs_task_max_seconds', 'value' => '20']);
|
||||
}
|
||||
|
||||
public function testPostSaveThrottlesSavesAndDeletesMissingThrottles(): void
|
||||
|
||||
Reference in new issue
Block a user