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

Add debug message on job fail #101

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pstray
Copy link

@pstray pstray commented Oct 3, 2020

Summary

Just a simple patch to add a debug log on job fail.

Could possibly add some check if there already are on-fail events hooks, but not sure how to do that :)

Motivation

I find it really useful to actually see if a job fail in the terminal running ./app minion worker, and not have to inspect the web interface or add promises or hooks to jobs.

References

Was discussed on #mojo earlier this week

@kraih
Copy link
Member

kraih commented Oct 3, 2020

Pretty sure i already said on IRC that this is not the right solution. The Mojo::Job class should not be tied to a Mojolicious app.

@kraih
Copy link
Member

kraih commented Oct 3, 2020

The job id is missing from the log message also. And debug is probably not the right level.

@kraih
Copy link
Member

kraih commented Oct 3, 2020

Not to mention the lack of tests.

@pstray
Copy link
Author

pstray commented Oct 5, 2020

Ok, moved the message from Minion/Job.pm to Minion/Command/worker/minion.pm. Sounds like a much more appropriate place for it.

Still no tests though, mostly because I have no idea how to test it :)

Wether it should be debug or some other level can be discussed, but the other messages in that file are debug, and for me, I mostly use such things for debugging. If you really want to do anything with those error messages, I guess you should handle them in other ways in the app itself.

@kraih
Copy link
Member

kraih commented Oct 5, 2020

That's a lot of code for what could have been a one-liner.

@pstray
Copy link
Author

pstray commented Oct 5, 2020

Removed one of the functions, _dequeue, and fixed the indentation and some spacing to match the other code. Still, a bit more than a one-liner, but that wouldn't be very readable code :)

$worker->on(dequeue => sub { pop->once(spawn => \&_spawn) });
$worker->on(dequeue => sub {
$_[1]->once(failed => \&_failed);
$_[1]->once(spawn => \&_spawn);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use $_[1] over multiple lines.

my($job, $error) = @_;
my($id, $task) = ($job->id, $job->task);
$error =~ s/\n//;
$job->app->log->debug(qq{Job "$id", task "$task" failed: $error});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message format is rather inconsistent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to provide positive feedback on what a a consistent message should look like instead....

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

Successfully merging this pull request may close these issues.

2 participants