Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not shutdown worker command when db is not accessible (feature) #20

Closed
Logioniz opened this issue Jan 15, 2016 · 3 comments
Closed

Not shutdown worker command when db is not accessible (feature) #20

Logioniz opened this issue Jan 15, 2016 · 3 comments

Comments

@Logioniz
Copy link

When the administrator shuts down the database, then need to restart the command worker after the start of the database.

Maybe add a key in the command line that the worker had not completed its work when the database is not available.

@kraih
Copy link
Member

kraih commented Jan 15, 2016

I'm afraid this feature request is too imprecise to be considered. What exactly is that command-line "key" supposed to do?

@kraih kraih closed this as completed Jan 15, 2016
@Logioniz
Copy link
Author

I know zero services which need to restart when restart db.

I believe code must look like something like that, but need correctly detect problem of connect to db:

$ git diff
diff --git a/lib/Minion/Command/minion/worker.pm b/lib/Minion/Command/minion/worker.pm
index f85738e..77e1428 100644
--- a/lib/Minion/Command/minion/worker.pm
+++ b/lib/Minion/Command/minion/worker.pm
@@ -22,8 +22,15 @@ sub run {
   my $app = $self->app;
   my $worker = $self->{worker} = $app->minion->worker;
   @$self{qw(register repair)} = (0, 0);
-  eval { $self->_work until $self->{finished} && !keys %{$self->{jobs}}; 1 }
-    or $app->log->fatal("Worker error: $@");
+  until ($self->{finished} && !keys %{$self->{jobs} // {}}) {
+    eval { $self->_work };
+    $app->log->fatal("Worker error: $@") if $@;
+    if ($@ && $@ =~ m/DBI connect/) { # don't know how correctly determine problem connect to db
+      sleep 5;
+    } else {
+      $self->{finished}++;
+    }
+  }
   $worker->unregister;
 }

@kraih
Copy link
Member

kraih commented Jan 15, 2016

I'm open to accepting a good patch for this, but it needs to be well thought out and take all the different backends into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants