Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better integration with queuedjobs #50

Open
sminnee opened this issue Nov 15, 2018 · 1 comment
Open

Better integration with queuedjobs #50

sminnee opened this issue Nov 15, 2018 · 1 comment

Comments

@sminnee
Copy link
Member

sminnee commented Nov 15, 2018

There's a couple of things that could be done to this module to make it work more nicely with queuedjobs.

  • Come bundled with a crontask for running the job queue
  • Reduce the amount of boilerplate needed to do crontask that adds a buildtask-execution to the job queue (a handy pattern for managing your background tasks)

This might be facilitated with #9

@sminnee
Copy link
Member Author

sminnee commented Mar 1, 2019

The following is used in a specific project to hook up queuedjobs. With a bit of checking to bypass the CronTask if Symbiote\QueuedJobs\Tasks\ProcessJobQueueTask didn't exist, it could be bundled in the crontask package.

However, it would probably necessitate a major version bump of this package, as people would need to disable any other executions of ProcessJobQueueTask they had set up.

Would that be reasonable?

<?php
use SilverStripe\CronTask\Interfaces\CronTask;
use Symbiote\QueuedJobs\Tasks\ProcessJobQueueTask;
use SilverStripe\Control\HTTPRequest;
/**
 * Trigger the queuedjob running from CronTask
 */
class QueuedJobsCron implements CronTask
{
    /**
     * Run every 6 hours
     *
     * @return string
     */
    public function getSchedule()
    {
        return "* * * * *";
    }
    /**
     * Run the build task SilverStripeElasticaReindexTask
     * @return void
     */
    public function process()
    {
        echo "Running ProcessJobQueueTask via CronTask...\n";
        $task = new ProcessJobQueueTask();
        $request = new HTTPRequest('GET', '/', []);
        $task->run($request);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants