Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
364 views
in Technique[技术] by (71.8m points)

php - The best way to run Laravel Queue with "proc_open" disabled?

I'm working on the project in Laravel hosted on a shared hosting, where PHP "proc_open" function is disabled.
I want to run "queue:listen" command, but "proc_open" is required by the Process class, so I'm getting the error "The Process class relies on proc_open, which is not available on your PHP installation".
I had the same situation with CRON and Kernel - "schedule:run" command was throwing the same error. Finally, I had to make my own Job Scheduler, task scheduling etc.
I know that maybe it wasn't necessary, but I couldn't find a workaround for this. Anyway, it was quite simple to make, but making custom queue-workers with all their data dependencies etc. seems to be more complicated and time-consuming.

What I've got now:

I've got few workers, for example MailWorker, which get tasks from Redis this way:

$tasks = $this->redis->lrange( 'queues:mail', 0, -1);
foreach( $tasks as &$task ){
    $task = $this->decodeTask($task);
}

private function decodeTask($task){
    $task = json_decode( $task );
    $task->data->command = unserialize( $task->data->command );

    return $task;
}

And they run tasks with their "handle()" method. However, I need to add the logic for locking tasks, marking them as failed etc. I worry that I'll miss something important and finally spend too much time on this task.

Is there a way to use the default solution? Maybe somebody already used some workaround for this problem?
Eventually: If my solution is the last possible, can you give me some informations what to focus on to make it work like the default Laravel solution?
Thanks in advance for every advice.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...