Run cron jobs via URL
Kanboard supports running cron jobs via CLI. There are hosting services that don't offer CLI access, but they do offer calling a URL periodically. This feature is often used as a CLI cron job replacement. This commit adds a CronjobController called by "/cronjob" URL that will execute cron jobs as they were executed via CLI. The URL has public access, but is protected using the webhook token. The "/cronjob" URL should be called via HTTPS.
This commit is contained in:
parent
87a94201aa
commit
5dae1e2e83
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Kanboard\Controller;
|
||||
|
||||
use Kanboard\Controller\BaseController;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
|
||||
/**
|
||||
* Class CronjobController
|
||||
*
|
||||
* Runs cron jobs via URL
|
||||
*
|
||||
* @package Kanboard\Controller
|
||||
*/
|
||||
class CronjobController extends BaseController
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$this->checkWebhookToken();
|
||||
|
||||
$input = new ArrayInput(array(
|
||||
'command' => 'cronjob',
|
||||
));
|
||||
$output = new NullOutput();
|
||||
|
||||
$this->cli->setAutoExit(false);
|
||||
$this->cli->run($input, $output);
|
||||
|
||||
$this->response->html('Cronjob executed');
|
||||
}
|
||||
}
|
||||
|
|
@ -143,6 +143,7 @@ class AuthenticationProvider implements ServiceProviderInterface
|
|||
$acl->add('FeedController', '*', Role::APP_PUBLIC);
|
||||
$acl->add('AvatarFileController', array('show', 'image'), Role::APP_PUBLIC);
|
||||
$acl->add('UserInviteController', array('signup', 'register'), Role::APP_PUBLIC);
|
||||
$acl->add('CronjobController', array('run'), Role::APP_PUBLIC);
|
||||
|
||||
$acl->add('ConfigController', '*', Role::APP_ADMIN);
|
||||
$acl->add('TagController', '*', Role::APP_ADMIN);
|
||||
|
|
|
|||
|
|
@ -180,6 +180,9 @@ class RouteProvider implements ServiceProviderInterface
|
|||
// PasswordReset
|
||||
$container['route']->addRoute('forgot-password', 'PasswordResetController', 'create');
|
||||
$container['route']->addRoute('forgot-password/change/:token', 'PasswordResetController', 'change');
|
||||
|
||||
// Cronjob
|
||||
$container['route']->addRoute('cronjob', 'CronjobController', 'run');
|
||||
}
|
||||
|
||||
return $container;
|
||||
|
|
|
|||
Loading…
Reference in New Issue