I want to use php_resque(https://github.com/chrisboulton/php-resque) for my codeigniter project. This is the function 'test' to create a new job.
public function test() {
$this->load->library('My_Job');
Resque::setBackend('localhost:6379');
$args = array(
'name' => 'Chris'
);
$token = Resque::enqueue('default', 'My_Job', $args, true);
$status = new Resque_Job_Status($token);
Resque::dequeue('default', ['My_Job' => $token]);
}
And this is the worker library code
putenv("VVERBOSE=1");
putenv("LOGGING=1");
putenv("QUEUE=*");
class My_Job {
public function perform($args) {
$this->load->model('M_sms');
$this->M_sms->ins_msg();
}
}
when i call 'test'(localhost/project_folder/controller/test), the 'perform' function in the worker(My_Job.php) is not loading. And Job status is 1. what is wrong here ?
when i used following code to debug
VERBOSE=1 QUEUE=default php resque.php
it says Could not find job class
In my code, the problem is, the worker do not know the location of job class. As i mentioned above, i am getting status 1 (STATUS_WAITING), which means 'Job is still queued'. This occurred to me because i tried to load the job class as a library in my codeigniter project.
$this->load->library('My_Job');
Now i changed my code according to this tutorial Programe Veryday
This tutorial explain step by step procedure to set up php-resque