Add possibility to run disabled cron
This commit is contained in:
parent
2fc288e53a
commit
552b9d3c33
4 changed files with 12 additions and 10 deletions
|
@ -156,10 +156,6 @@ class ScheduleController extends ClientApiController
|
|||
*/
|
||||
public function execute(TriggerScheduleRequest $request, Server $server, Schedule $schedule)
|
||||
{
|
||||
if (!$schedule->is_active) {
|
||||
throw new BadRequestHttpException('Cannot trigger schedule exection for a schedule that is not currently active.');
|
||||
}
|
||||
|
||||
$this->service->handle($schedule, true);
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_ACCEPTED);
|
||||
|
|
|
@ -27,13 +27,19 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||
*/
|
||||
public $task;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $now;
|
||||
|
||||
/**
|
||||
* RunTaskJob constructor.
|
||||
*/
|
||||
public function __construct(Task $task)
|
||||
public function __construct(Task $task, $now = false)
|
||||
{
|
||||
$this->queue = config('pterodactyl.queues.standard');
|
||||
$this->task = $task;
|
||||
$this->now = $now;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,8 +52,8 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||
InitiateBackupService $backupService,
|
||||
DaemonPowerRepository $powerRepository
|
||||
) {
|
||||
// Do not process a task that is not set to active.
|
||||
if (!$this->task->schedule->is_active) {
|
||||
// Do not process a task that is not set to active, unless it's been trigger by the run now API.
|
||||
if ($this->task->schedule->is_active && !$this->now) {
|
||||
$this->markTaskNotQueued();
|
||||
$this->markScheduleComplete();
|
||||
|
||||
|
@ -101,7 +107,7 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||
|
||||
$nextTask->update(['is_queued' => true]);
|
||||
|
||||
$this->dispatch((new self($nextTask))->delay($nextTask->time_offset));
|
||||
$this->dispatch((new self($nextTask, $this->now))->delay($nextTask->time_offset));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,7 +53,7 @@ class ProcessScheduleService
|
|||
$task->update(['is_queued' => true]);
|
||||
});
|
||||
|
||||
$job = new RunTaskJob($task);
|
||||
$job = new RunTaskJob($task, $now);
|
||||
|
||||
if (!$now) {
|
||||
$this->dispatcher->dispatch($job->delay($task->time_offset));
|
||||
|
|
|
@ -161,7 +161,7 @@ export default () => {
|
|||
onDeleted={() => history.push(`/server/${id}/schedules`)}
|
||||
/>
|
||||
</Can>
|
||||
{schedule.isActive && schedule.tasks.length > 0 &&
|
||||
{schedule.tasks.length > 0 &&
|
||||
<Can action={'schedule.update'}>
|
||||
<RunScheduleButton schedule={schedule}/>
|
||||
</Can>
|
||||
|
|
Loading…
Reference in a new issue