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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.