aarondfrancis / laravel-pseudo-daemon

A Laravel package to mimic daemons via scheduled commands without having to change server configuration.
92 stars 12 forks source link

Running multiple daemons in parallel? #3

Closed tontonsb closed 3 years ago

tontonsb commented 3 years ago

Hey, thanks for this package and sorry for bothering you with usage questions/feature requests.

Currently withoutOverlapping causes this to run on a single thread only. My use case involves waiting for an API response, so I would like to have multiple pollers running simultaneously.

Could I somehow do that? At the moment the only solution seems to duplicate my commands, i.e. make poller2:work, poller3:work etc.

aarondfrancis commented 3 years ago

Good question! The way we do it is to have a nonsense optional argument. Here's an excerpt from our Kernel, in this case we use process-num as the uniqueness provider.

// Run 3 import processes. The process-num arg is just
// there to make them unique so that withoutOverlapping
// can keep them separate.
$schedule->command('imports:process --process-num=1')->everyMinute();
$schedule->command('imports:process --process-num=2')->everyMinute();
$schedule->command('imports:process --process-num=3')->everyMinute();