magento2-dockergento icon indicating copy to clipboard operation
magento2-dockergento copied to clipboard

Period of 502 Bad Gateway

Open erfanimani opened this issue 6 years ago • 6 comments

Hi there,

Firstly, thanks for providing such a useful Docker environment — the best and fastest I've tried for Magento 2 development so far.

After every restart, there's a period where the web server will "502 Bad Gateway" instantly. At first this was quite annoying because I don't have an indication of when it has "finished" restarting, even though the command itself works quickly. Now I just look at OSX Activity Monitor, and check when the CPU has died down; com.docker.hyperkit will use 120%+ CPU during the 502 error, but Nginx will work well after the CPU has done "doing its thing".

What is it actually doing? Is there a verbose command option that ensures the work is done synchronously? On a large project with app and pub as delegated mounts this is now taking multiple minutes to finish, and it can be quite annoying because as you know, the container restarts often (during copy operations, debugging on/off, etc).

Happy to look into this myself.. I might need some tips.

Thanks

erfanimani avatar Apr 18 '19 06:04 erfanimani

Hi @erfanimani thanks for your help. I'm also experiencing that in some projects (it's more visible in large projects with a big ammount of code).

I don't have much information about that, but I think that containers in mac behave different than in linux because of the filesystem. Docker for mac can't use "native" filesystem and it needs some kind of virtualization, so probably docker for mac is making virtual mounts and copying files inside it (the reason of the bad performance).

I don't recomend you to mount pub, because the filesystem sync in docker for mac is really slow, you could use a volume and do a sync container -> host like we do with vendor (watch command).

Maybe you can do a deeper debug using the Console app for Mac.

I'm sorry for not being more helpful, if you need something please let us know!

danielozano avatar Apr 18 '19 14:04 danielozano

Thanks Daniel, this was very helpful actually. I'll experiment some more and update the ticket.

On Thu, Apr 18, 2019, 22:13 Daniel Lozano [email protected] wrote:

Hi @erfanimani https://github.com/erfanimani thanks for your help. I'm also experiencing that in some projects (it's more visible in large projects with a big ammount of code).

I don't have much information about that, but I think that containers in mac behave different than in linux because of the filesystem. Docker for mac can't use "native" filesystem and it needs some kind of virtualization, so probably docker for mac is making virtual mounts and copying files inside it (the reason of the bar performance).

I don't recomend you to mount pub, because the filesystem sync in docker for mac is really slow, you could use a volume and do a sync container -> host like we do with vendor (watch command).

Maybe you can do a deeper debug using the Console app for Mac https://docs.docker.com/docker-for-mac/troubleshoot/#check-the-logs.

I'm sorry for not being more helpful, if you need something please let us know!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ModestCoders/magento2-dockergento/issues/47#issuecomment-484527866, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHDFJSHXABUNKHS77T3Q2LPRB6YBANCNFSM4HG2DZTQ .

erfanimani avatar Apr 19 '19 02:04 erfanimani

Hi, as far as I investigated you get a 502 Bad Gateway until the phpfpm container logs the "fpm is ready to handle connections" which takes approximately 15 seconds on my mac.

You can see that with a dockergento docker-compose logs -f after starting the containers. The 502s are apparently caused by an unavailable docker socket.

frighi-onestic avatar Apr 26 '19 16:04 frighi-onestic

Hi, as far as I investigated you get a 502 Bad Gateway until the phpfpm container logs the "fpm is ready to handle connections" which takes approximately 15 seconds on my mac.

You can see that with a dockergento docker-compose logs -f after starting the containers. The 502s are apparently caused by an unavailable docker socket.

phpfpm_1 | [03-May-2019 10:23:57] NOTICE: ready to handle connections nginx_1 | 2019/05/03 10:22:40 [notice] 1#1: using the "epoll" event method

it takes more than 1 min for me!

sanaeefar-saeed avatar May 03 '19 10:05 sanaeefar-saeed

@danielozano How would one go about changing pub to be mounted the same way as vendor? I've got 88GB of images in my pup folder and it takes over an hour to spin up.

powelles avatar Jan 30 '20 03:01 powelles

@powelles if it helps, I don't actually mount pub at all. I just run dockergento mirror-host /path/to/pub and leave it — there's no need for me to keep it in sync, but your use case may vary.

erfanimani avatar Jan 30 '20 10:01 erfanimani