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 task queue:restart for Laravel recipe #1007

Merged
merged 2 commits into from
Feb 18, 2017
Merged

Add task queue:restart for Laravel recipe #1007

merged 2 commits into from
Feb 18, 2017

Conversation

lasselehtinen
Copy link
Contributor

Q A
Bug fix? No
New feature? Yes
BC breaks? No
Deprecations? No
Fixed tickets N/A

Laravel has an artisan command to send a restart signal to the queue workers. This is kind of a must during deployment. I noticed that the Laravel recipe does not have this artisan command, so here is a PR to add this command.

https://laravel.com/docs/5.4/queues#queue-workers-and-deployment

@lasselehtinen lasselehtinen changed the title Added task for queue:restart Added task queue:restart for Laravel recipe Feb 13, 2017
@lasselehtinen lasselehtinen changed the title Added task queue:restart for Laravel recipe Add task queue:restart for Laravel recipe Feb 13, 2017
desc('Execute artisan queue:restart');
task('artisan:queue:restart', function () {
run('{{bin/php}} {{release_path}}/artisan queue:restart');
writeln('<info>' . $output . '</info>');
Copy link
Member

Choose a reason for hiding this comment

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

$output is undefined. There is no need of writing output here.

@antonmedv
Copy link
Member

Also, please add this to deploy flow and CHANGELOG.md.

@lasselehtinen
Copy link
Contributor Author

lasselehtinen commented Feb 13, 2017

I am not sure actually if there is a point for displaying the output at all, since it is pretty much fixed. So I removed it.

I added task to the the deployment flow as you asked. Please note that not all Laravel applications use queues, but I guess it is a sensible default. But the command works even if you have set the queue driver to "sync" so there is no harm done.

@antonmedv
Copy link
Member

@lasselehtinen so it's safe for all laravel users? If them not using queue?

@lasselehtinen
Copy link
Contributor Author

@Elfet Yes it is safe to run always but might not be always necessary. Personally I have queue jobs on pretty much on all Laravel projects, but that is just me. But with a gut feeling as there is no statistics that larger majority uses the queue for sending emails, notifications etc. It is a non-blocking operation so it takes only one seconds or less.

@antonmedv
Copy link
Member

Well, maybe its better to not include this to recipe, but to template of laravel? So users can customize it easily.

@lasselehtinen
Copy link
Contributor Author

Yes I guess that is a best option, you can easily add after('artisan:optimize', 'artisan:queue:restart'); in your deployment if you are using queues. I've updated the PR.

I guess that is something that could be covered in the recipe documentation, but I noticed there is no documentation for the Laravel recipe. I will try to contribute on that when I have time.

@pluseg
Copy link
Contributor

pluseg commented Feb 17, 2017

@Elfet, it waits your approve and merge.

@antonmedv antonmedv merged commit b8a4207 into deployphp:master Feb 18, 2017
@barryvdh
Copy link
Contributor

barryvdh commented Apr 5, 2017

I think this should be added by default. It doesn't hurt anyone, it's only creating a cache instance: https://github.com/laravel/framework/blob/5.4/src/Illuminate/Queue/Console/RestartCommand.php

So no effect for people not using queue, but very much required for everyone who is using queues!

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

Successfully merging this pull request may close these issues.

4 participants