Custom Task Queue
-
Hi, You can certainly use the task queue for custom commands. You need a task processor for your custom commands. Development documentation is available on CPAN: cPanel::TaskQueue::Cookbook - some tasty uses of the cPanel::TaskQueue modules. - metacpan.org 0 -
Hi, Thank a lot for your answer, it's a good new ! I'm not familiar with Perl but I will take a look, I think it will worth my time as I don't want to implement (and monitor) a queue system myself. 0 -
Is there a newer version of the development documentation given above? I'm curious if there's a specific place to place the processors.
0 -
The documentation 404s.
0 -
Howdy Koree,
Honestly I'd just look at what we did for the old Calendar and Contacts plugin (cpanel-ccs-calendarserver); I had a custom TaskProcessor module there. It installs to /var/cpanel/perl/Cpanel/TaskProcessors/CCSTasks.pm
Otherwise you can look at the other modules in Cpanel/TaskProcessors/ as well, lots of good examples there if you need your own custom processor module.
IIRC all we had to do after putting the taskprocessor module there was restart queueprocd and then it could accept and process jobs we queued from it.
Example of queueing a job for immediate processing:
Cpanel::ServerTasks::queue_task( ['CCSTasks'], "flush_memcached" );
Example of queueing a job 60s in the future:
Cpanel::ServerTasks::schedule_task( ['CCSTasks'], 60, "safe_configure_postgres_for_cpanel" );
Hope this helps!
1 -
I'm essentially trying to create a queue processor for sa-learn. Thank you for the detail! I'll check out the existing TaskProcessors. I'm currently getting this error. [root@cpanel-2 taskqueue]# /usr/local/cpanel/3rdparty/bin/perl /usr/local/cpanel/scripts/process_sa_learn_queue.pl koree@koree.net foo ham
Attempting to use state file: /var/cpanel/taskqueue/state/sa_learn_queue.state
No state filename supplied. at /usr/local/cpanel/Cpanel/StateFile.pm line 491.0 -
I think I've figured this out. I was doing some dumb stuff. I'll report back.
0
Please sign in to leave a comment.
Comments
7 comments