vendredi 12 février 2016

Running artisan queue:work with additional arguments

I am trying to run queued jobs, and pass additional parameters through the command line. My use case is this:

I have 4 running queue:work processes through supervisor. The jobs in my queue all require access to a proxy server, through which i can only have 4 processes running at any given time. When I start up a queued job, I have to find a process number (1 through 4) that is not currently being used, then run my command through that process.

I have been using a database table to store the processes and it has a column for in_use which keeps track of whether its being used, but the problem I'm seeing is when two queue:work commands run simultaneously, the same proxy process can be picked from the database for both.

What I want

php artisan queue:work --process=1

Then to somehow retrieve that argument inside the job, so I can run my 4 processes each in supervisor separately.

As a workaround, I have created a custom artisan command which will take the argument, but I then lose the queue functionality. I don't want to have to develop a custom queue process.

Is there a way to pass this argument? Or, alternatively, is there a way that I could pop jobs off the queue from within my custom artisan command, and then run them manually rather than through queue:work?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire