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

Exit listen action when throw exception #10

Closed
airani opened this issue Feb 25, 2017 · 6 comments
Closed

Exit listen action when throw exception #10

airani opened this issue Feb 25, 2017 · 6 comments

Comments

@airani
Copy link
Contributor

airani commented Feb 25, 2017

Hi
I want exit from listening when throw a new exception in my job and want get errors in error logs not in verbose logs

@zhuravljov
Copy link
Member

You can use LogBehavior to write logs after each job. Configure example:

'queue' => [
    'class' => \zhuravljov\yii\queue\Queue::class,
    'as log' => \zhuravljov\yii\queue\LogBehavior::class,
],

If you need to exit from listening when throw a new exception use Queue::EVENT_AFTER_ERROR:

'queue' => [
    'class' => \zhuravljov\yii\queue\Queue::class,
    'on afterError' => function (\zhuravljov\yii\queue\ErrorEvent $event) {
        throw $event->error;
    }
],

@airani
Copy link
Contributor Author

airani commented Apr 25, 2017

@zhuravljov
How can exit from listener worker?
After throw an exception wrote error in stdout and don't exit from worker and worker locked! and with below code i can't exit from worker!

'queue' => [
    'class' => \zhuravljov\yii\queue\Queue::class,
    'on afterError' => function (\zhuravljov\yii\queue\ErrorEvent $event) {
        throw $event->error;
    }
],

What can i do?

@zhuravljov
Copy link
Member

zhuravljov commented Apr 26, 2017

Beginning from 0.12.0 a job is executed isolatly in a child process. So a job executing doesn't affect on a listener. I will make separate option that would disable this. For example:

php yii queue/listen --isolate=0

@zhuravljov zhuravljov reopened this Apr 26, 2017
@airani
Copy link
Contributor Author

airani commented Apr 26, 2017

What is benefits of isolate listener? when job stuck in worker and locked worker?

@zhuravljov
Copy link
Member

zhuravljov commented Apr 26, 2017

Some components are designed for a short life cycle. And they will be broken, if a job is executed in main process, which works in daemon mode for a long time. There are #8 and #12 reports about lost connections of db and mailer components.

@airani
Copy link
Contributor Author

airani commented Apr 26, 2017

Thank you, I waiting for "isolate" option

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