Feat: cron jobs are executed based on the server timezone

This commit is contained in:
ayntk-ai
2024-08-16 12:58:19 +02:00
parent a478ebef2e
commit 1892ce4e12
2 changed files with 13 additions and 5 deletions

View File

@@ -36,6 +36,8 @@ class ScheduledTaskJob implements ShouldQueue
public array $containers = [];
public string $server_timezone;
public function __construct($task)
{
$this->task = $task;
@@ -47,6 +49,7 @@ class ScheduledTaskJob implements ShouldQueue
throw new \RuntimeException('ScheduledTaskJob failed: No resource found.');
}
$this->team = Team::find($task->team_id);
$this->server_timezone = $this->resource->destination->server->settings->server_timezone;
}
public function middleware(): array
@@ -61,6 +64,7 @@ class ScheduledTaskJob implements ShouldQueue
public function handle(): void
{
try {
$this->task_log = ScheduledTaskExecution::create([
'scheduled_task_id' => $this->task->id,
@@ -121,6 +125,8 @@ class ScheduledTaskJob implements ShouldQueue
$this->team?->notify(new TaskFailed($this->task, $e->getMessage()));
// send_internal_notification('ScheduledTaskJob failed with: ' . $e->getMessage());
throw $e;
} finally {
}
}
}
}