S2OJ/web/app/scheduler.php
2023-02-13 20:29:32 +08:00

32 lines
705 B
PHP

<?php
$_SERVER['DOCUMENT_ROOT'] = dirname(__DIR__);
require_once $_SERVER['DOCUMENT_ROOT'] . '/app/vendor/autoload.php';
require $_SERVER['DOCUMENT_ROOT'] . '/app/libs/uoj-lib.php';
// Create a new scheduler
$scheduler = new GO\Scheduler([
'tempDir' => '/tmp'
]);
echo '[UOJScheduler] Init', "\n";
// =========== JOBS ===========
// Email
$scheduler->call('UOJMail::cronSendEmail', [], 'cronSendEmail')
->at('* * * * *')
->onlyOne()
->before(function () {
echo "[cronSendEmail] started at " . time() . "\n";
})
->then(function () {
echo "[cronSendEmail] ended at " . time() . "\n";
});
// ============================
// Let the scheduler execute jobs which are due.
$scheduler->run();