Skip to content

Commit 552b9d3

Browse files
committed
Add possibility to run disabled cron
1 parent 2fc288e commit 552b9d3

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

app/Http/Controllers/Api/Client/Servers/ScheduleController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ public function update(UpdateScheduleRequest $request, Server $server, Schedule
156156
*/
157157
public function execute(TriggerScheduleRequest $request, Server $server, Schedule $schedule)
158158
{
159-
if (!$schedule->is_active) {
160-
throw new BadRequestHttpException('Cannot trigger schedule exection for a schedule that is not currently active.');
161-
}
162-
163159
$this->service->handle($schedule, true);
164160

165161
return new JsonResponse([], JsonResponse::HTTP_ACCEPTED);

app/Jobs/Schedule/RunTaskJob.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ class RunTaskJob extends Job implements ShouldQueue
2727
*/
2828
public $task;
2929

30+
/**
31+
* @var bool
32+
*/
33+
public $now;
34+
3035
/**
3136
* RunTaskJob constructor.
3237
*/
33-
public function __construct(Task $task)
38+
public function __construct(Task $task, $now = false)
3439
{
3540
$this->queue = config('pterodactyl.queues.standard');
3641
$this->task = $task;
42+
$this->now = $now;
3743
}
3844

3945
/**
@@ -46,8 +52,8 @@ public function handle(
4652
InitiateBackupService $backupService,
4753
DaemonPowerRepository $powerRepository
4854
) {
49-
// Do not process a task that is not set to active.
50-
if (!$this->task->schedule->is_active) {
55+
// Do not process a task that is not set to active, unless it's been trigger by the run now API.
56+
if ($this->task->schedule->is_active && !$this->now) {
5157
$this->markTaskNotQueued();
5258
$this->markScheduleComplete();
5359

@@ -101,7 +107,7 @@ private function queueNextTask()
101107

102108
$nextTask->update(['is_queued' => true]);
103109

104-
$this->dispatch((new self($nextTask))->delay($nextTask->time_offset));
110+
$this->dispatch((new self($nextTask, $this->now))->delay($nextTask->time_offset));
105111
}
106112

107113
/**

app/Services/Schedules/ProcessScheduleService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function handle(Schedule $schedule, bool $now = false)
5353
$task->update(['is_queued' => true]);
5454
});
5555

56-
$job = new RunTaskJob($task);
56+
$job = new RunTaskJob($task, $now);
5757

5858
if (!$now) {
5959
$this->dispatcher->dispatch($job->delay($task->time_offset));

resources/scripts/components/server/schedules/ScheduleEditContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export default () => {
161161
onDeleted={() => history.push(`/server/${id}/schedules`)}
162162
/>
163163
</Can>
164-
{schedule.isActive && schedule.tasks.length > 0 &&
164+
{schedule.tasks.length > 0 &&
165165
<Can action={'schedule.update'}>
166166
<RunScheduleButton schedule={schedule}/>
167167
</Can>

0 commit comments

Comments
 (0)