On Fri, Mar 29, 2019 at 9:27 AM Veesh Goldman <[email protected]> wrote:
> I have a mojolicious app which acts as a frontend to a resource, and
> requires a websocket connection to that resource. I would like to run some
> stuff in the background with Minion, but I don't want minion to also have
> that connection. How would I make only the server and not the worker run
> that code?
>
> #TODO- only run vvvv this in the server, not the worker
> app->ua->websocket( 'ws://my.resource' => sub { ... } ); #control things
>
You could inspect the command line arguments or environment.
I start my minion with `myapp.pl minion worker' so:
app->ua->websocket( 'ws://my.resource' => sub { ... } ) unless grep {
/worker/ } @ARGV;
Or using env with `env MINION=1 myapp.pl minion worker`
app->ua->websocket( 'ws://my.resource' => sub { ... } ) unless
$ENV{MINION};
There may be a more elegant way, but this at least demonstrates what might
be easily missed when it comes to figuring out how to solve that problem.
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.