Hello,
I've read the Beanstalk documentation, as well as a similar question. My scenario is the following:
- an apache/Phalcon micro-app receives jobs from another server
- I run the jobs using PHP/libvirt/ssh
- I create some package and keep it locally for serving
At no moment is there a view, HTML or CSS used. This is all for back-end processing.
I've followed the guide to creating a Beanstalk queue and adding objects.
Within the same class is also the process_job method.
class master
{
    public static function make_jobs($kvms)
    {
        $queue = new Beanstalk(array('host' => 'localhost', 'port' => '11300'));
        foreach ($kvms as $kvm) {
            $job = new queue_job($kvm);
            $queue->put(array('process_job' => $job));
        }
    }
    public static function process_job($job)
    {
        print_r($job);
    }What is not clear from either the documentation or the forum questions, is where do I set the background worker? How can I dispatch either an event listener which will be alerted of new Beanstalk jobs, or a handler which will infinetely loop for beanstalk jobs, similar to the example from the documentation:
while (($job = $queue->peekReady()) !== false) {
    $jobBody = $job->getBody();
    // ... do the actual job which will take some time
    $job->delete();
}Any help is greatly appreciated.