Discussion:
Minion jobs stay "inactive"
(too old to reply)
Winni Neessen
2015-11-06 06:39:59 UTC
Permalink
Hi,

I am trying to get some background jobs done with Minion within my
Mojolicious app. I've installed Mojolicious::Plugin::Minion
and set it up in my startup() sub:

23 sub startup {
24 my $self = shift;
[...]
32 $self->plugin(Minion => {Pg => 'postgresql://mojo@/mojo'});
33 $self->app->minion->on(worker => sub {
34 my ($minion, $worker) = @_;
35 $self->app->log->debug('Worker started: ' . Dumper $worker->id);
36 });
37 $self->app->minion->add_task(test_job => sub {
38 my ($job, @args) = @_;
39 sleep 5;
40 $job->app->log->debug('This is a background worker process');
41 });

(I tried the SQLite backend as well)

The first thing I noticed, is that the worker->id in my "on worker" event
is always undef when I start a worker
using ./script/my_app minion worker.

When I now enqueue a job in my Api-call Controller:

30 ## Post a file and start the processing // scanFile() {{{
31 sub scanFile {
32 my $self = shift;
33 my $uploadedFile = $self->param('file');
34
[...]
41 ## Minion testing
42 my $jobId = $self->app->minion->enqueue(test_job => ['testing']);

I can see that my job is shown via ./script/my_app minion job (and also
when I look at the minion_jobs table
in the PgSQL database) but the job stays inactive. From the examples on the
ma page, I can't find any hint
that I have to activate the jobs manually, so I would assume that the jobs
should be taken by the worker
when they are queued and then worked on. But this simply doesn't happen -
they stay inactive all the time.
They only get executed, if I run a $self->app->minion->perform_jobs;

Any hint why this is happening or am I doing something completely wrong (or
is my assumption, that jobs
are automatically worked on) wrong at all?

Any help is highly appreciated!
Thanks
Winni
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
sri
2015-11-06 10:16:23 UTC
Permalink
Post by Winni Neessen
33 $self->app->minion->on(worker => sub {
Calling $self->app does nothing else than waste CPU, your $self is already
the app.

The first thing I noticed, is that the worker->id in my "on worker" event
Post by Winni Neessen
is always undef when I start a worker
using ./script/my_app minion worker.
Because the worker event gets emitted before the worker has registered
itself.

They only get executed, if I run a $self->app->minion->perform_jobs;
That's a good sign, it means the worker basically works.

Any hint why this is happening or am I doing something completely wrong (or
Post by Winni Neessen
is my assumption, that jobs
are automatically worked on) wrong at all?
Odds are you are doing something completely wrong, but it is not mentioned
here, like using an entirely different app for starting the worker.

--
sebastian
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
sri
2015-11-06 10:19:48 UTC
Permalink
For testing purposes i'd suggest using the self-contained lite app from the
documentation.

http://mojolicio.us/perldoc/Minion#DESCRIPTION

--
sebastian
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Winni Neessen
2015-11-06 10:47:08 UTC
Permalink
Hi Sebastian,
Post by sri
For testing purposes i'd suggest using the self-contained lite app from
the documentation.
http://mojolicio.us/perldoc/Minion#DESCRIPTION
Thanks for the hint. Due to the Lite-app approach, I was able to identify
the problem. With the lite app everything worked fine.
The difference I found is, that i started my actual app with "morbo". When
I start it the following way:

env DBIC_TRACE=1 morbo -l http://0.0.0.0:5000 script/my_app -v -w lib -w
conf -w templates


the queue is not worked on. If I use the "daemon" helper:
./script/av_scan daemon -l http://0.0.0.0:5000
the queue is worked on.

Is morbo not capable of Minion or what am I missing?

Thanks!
Winni
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Winni Neessen
2015-11-06 10:57:05 UTC
Permalink
Nevermind... for some weird reason (which I can't explain), it now works
with morbo as well.
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
sri
2015-11-06 10:57:23 UTC
Permalink
Post by Winni Neessen
Is morbo not capable of Minion or what am I missing?
That makes no sense at all, are we not talking about the worker command
anymore?

--
sebastian
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...