mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 04:04:45 +02:00
Make sure schedules run with UTC (#657)
* make sure schedules use UTC for `next_run_at` * use function from Utilities
This commit is contained in:
parent
60792c05c2
commit
c53ef78d89
@ -6,7 +6,6 @@ use Illuminate\Console\Command;
|
|||||||
use App\Models\Schedule;
|
use App\Models\Schedule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use App\Services\Schedules\ProcessScheduleService;
|
use App\Services\Schedules\ProcessScheduleService;
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class ProcessRunnableCommand extends Command
|
class ProcessRunnableCommand extends Command
|
||||||
{
|
{
|
||||||
@ -24,7 +23,7 @@ class ProcessRunnableCommand extends Command
|
|||||||
->whereRelation('server', fn (Builder $builder) => $builder->whereNull('status'))
|
->whereRelation('server', fn (Builder $builder) => $builder->whereNull('status'))
|
||||||
->where('is_active', true)
|
->where('is_active', true)
|
||||||
->where('is_processing', false)
|
->where('is_processing', false)
|
||||||
->where('next_run_at', '<=', Carbon::now()->toDateTimeString())
|
->where('next_run_at', '<=', now('UTC')->toDateTimeString())
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
if ($schedules->count() < 1) {
|
if ($schedules->count() < 1) {
|
||||||
|
@ -40,7 +40,7 @@ class Utilities
|
|||||||
{
|
{
|
||||||
return Carbon::instance((new CronExpression(
|
return Carbon::instance((new CronExpression(
|
||||||
sprintf('%s %s %s %s %s', $minute, $hour, $dayOfMonth, $month, $dayOfWeek)
|
sprintf('%s %s %s %s %s', $minute, $hour, $dayOfMonth, $month, $dayOfWeek)
|
||||||
))->getNextRunDate());
|
))->getNextRunDate(now('UTC')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checked(string $name, mixed $default): string
|
public static function checked(string $name, mixed $default): string
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Cron\CronExpression;
|
use App\Helpers\Utilities;
|
||||||
use Carbon\CarbonImmutable;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
@ -112,13 +111,9 @@ class Schedule extends Model
|
|||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function getNextRunDate(): CarbonImmutable
|
public function getNextRunDate(): string
|
||||||
{
|
{
|
||||||
$formatted = sprintf('%s %s %s %s %s', $this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_month, $this->cron_day_of_week);
|
return Utilities::getScheduleNextRunDate($this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_month, $this->cron_day_of_week)->toDateTimeString();
|
||||||
|
|
||||||
return CarbonImmutable::createFromTimestamp(
|
|
||||||
(new CronExpression($formatted))->getNextRunDate()->getTimestamp()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user