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

Being able to check currently live/unfinished requests #30456

Open
BentCoder opened this Issue Mar 5, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@BentCoder
Copy link

BentCoder commented Mar 5, 2019

Hi,

I think it would be nicer if I use an example scenario.

Assume that I run a command that checks if there is currently a live request being processed in the app (obviously the response hasn't been returned yet). If the app is free from requests then run some logic. Otherwise wait for all existing requests to be finished first.

Same time the command should prevent new requests coming in otherwise the logic will probably never run in very busy apps.

Does this make sense?

Thanks

@javiereguiluz

This comment has been minimized.

Copy link
Member

javiereguiluz commented Mar 6, 2019

At first sight this looks like a too specific feature to be included in the Symfony core. Also, there should be already alternative ways of implementing this:

  • If you want to run something after some deploy and before the new requests arrive, there are deployment techniques that allow you tu run commands before/during/after deployment and before enabling the new deployed version.
  • If it's about "locking" access to resources to prevent other requests from changing/accessing what your console command is editing/generating, you can use the Lock component: https://symfony.com/doc/current/components/lock.html
@BentCoder

This comment has been minimized.

Copy link
Author

BentCoder commented Mar 6, 2019

Much appreciated with your response. My exact case is this:

  1. I deploy a dockerised Symfony app - (nginx, mysql and php-fpm as containers).
  2. Before running the doctrine:migration:migrate command in php-fpm container, I want all current requests be finished first.
  3. Once there is no request, run the doctrine:migration:migrate command.

The reason why I am actually asking this is because, there will be cases I'll be renaming existing tables in DB which would be problem if there was live requests that depend on old table name.

What is your suggestion on this? If there is a solution for this, could you please direct me to the resource?

Thanks

@maartendekeizer

This comment has been minimized.

Copy link

maartendekeizer commented Mar 10, 2019

Sent a gracefull shutdown command to Nginx. After Nginx stopt theire are no active connections left and you can safely run your migration. When using other load ballancing software it is also possible to use thinks like connection draining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.