Hello,

I need some help about the interaction when Mojolicious and Minion working 
together.

I have the full Mojolicious code where I load the Minion as a plugin and 
using Pg as a backend. 

sub status {
        my $c = shift;
        $c->render(json =>  $c->app->minion->stats, status => 200 );
        return;
}

This is showing me the following output when the worker is not running:
{"active_jobs":0,"active_workers":0,"delayed_jobs":0,"enqueued_jobs":43,"failed_jobs":0,"finished_jobs":0,"inactive_jobs":7,"inactive_workers":0}

After I start the minion worker in a different terminal on the same host 
and code:
{"active_jobs":0,"active_workers":0,"delayed_jobs":0,"enqueued_jobs":43,"failed_jobs":0,"finished_jobs":0,"inactive_jobs":7,"inactive_workers":1}

Inactive worker number increases as expected. 

I am planning to use the following endpoint to post a costly long running 
background job:

sub rescan {
my $c = shift;
my $minion = $c->app->minion;
$minion->add_task( 'rescan' => sub{
my $job = shift;
$job->app->SCSICleanup($job);
});
$minion->enqueue('rescan');
$c->render(json => {Service => 'Rescan'}, status => 200 );
return; 
}

After I called the rescan function I have the following job in the 
database: (select * from minion_jobs order by id desc limit 1 ;)
44;"[]";"2017-06-02 16:58:52.252232+01";"2017-06-02 
16:58:52.252232+01";"";0;"";"";0;"";"inactive";"rescan";;"default";1;"{}"

The job remain inactive even if the worker is running.
In the development.log I have the following - worker restarted after code 
changes:
[Fri Jun  2 17:04:09 2017] [debug] Loading Plugin Helpers
[Fri Jun  2 17:04:09 2017] [debug] Loading Plugin Database
[Fri Jun  2 17:04:09 2017] [debug] Initialise database connection
[Fri Jun  2 17:04:09 2017] [debug] Database Version: PostgreSQL 9.5.7 on 
x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu
1~16.04.4) 5.4.0 20160609, 64-bit
[Fri Jun  2 17:04:09 2017] [debug] Loading Plugin Minion
[Fri Jun  2 17:04:09 2017] [debug] Loading Plugin SCSI
[Fri Jun  2 17:04:09 2017] [debug] Loading Plugin Jobs
[Fri Jun  2 17:04:09 2017] [debug] Worker 4127 started
[Fri Jun  2 17:04:09 2017] [debug] Checking worker registry and job queue


I tried the following modification:
sub rescan {
my $c = shift;
my $minion = $c->app->minion;
$minion->add_task( 'rescan' => sub{
my $job = shift;
$job->app->SCSICleanup($job);
});
my id = $minion->enqueue('rescan');
$minion->job($id)->start;
$c->render(json => {Service => 'Rescan'}, status => 200 );
return; 
}

After the modification the situation is exactly the same:
45;"[]";"2017-06-02 17:04:12.067348+01";"2017-06-02 
17:04:12.067348+01";"";0;"";"";0;"";"inactive";"rescan";;"default";1;"{}"

Could you please help me what I am doing wrong or what I missed ? 

Regards,
Arpad

-- 
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.

Reply via email to