zendframework / zend-expressive-swoole

Swoole support for Expressive applications
BSD 3-Clause "New" or "Revised" License
158 stars 14 forks source link

Dockerized container does not restart properly #47

Closed MassiAtHG closed 5 years ago

MassiAtHG commented 5 years ago

A containerised expressive app running with Swoole HTTP server (latest version 2) does not restart. The error generated after the restart is the following:

Swoole is running at 0.0.0.0:81, in /app
Worker started in /app with ID 0
Worker started in /app with ID 4
Worker started in /app with ID 3
Worker started in /app with ID 1
Worker started in /app with ID 2
Worker started in /app with ID 7
Worker started in /app with ID 5
Worker started in /app with ID 6
172.16.239.1 - - [21/Nov/2018:10:39:27 +0000] "PATCH /user HTTP/1.1" 500 13211
[2018-11-21 10:42:57 #1.0]      NOTICE  Server is shutdown now.
Server is already running!

Container ENTRYPOINT ["php", "/app/vendor/bin/zend-expressive-swoole", "start"]

I believe the problem is related to the PidManager not clearing the file on SIGTERM or the subsequent SIGKILL.

acelaya commented 5 years ago

I have workaround this issue with this.

until php ./vendor/bin/zend-expressive-swoole start; do sleep 1 ; done

It's quiet hacky, but it basically retries the start command every second until it succeeds. It usually works after two retries if not in the first one.