ohler55 / agoo

A High Performance HTTP Server for Ruby
MIT License
912 stars 39 forks source link

Port cleanup on shutdown? #97

Closed tomas closed 4 years ago

tomas commented 4 years ago

I'm comparing RAM & CPU usage between Agoo and Puma and something weird just happened.

After shutting down Agoo via Ctrl-C I cannot launch Puma on the same port because it complains about the port being in use:

Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 9292

However if I restart Agoo on the very same port it launches without any problems.

Do you know what might be going on?

Agoo 2.13.0 with pid 23628 is listening on http://:9292.
ohler55 commented 4 years ago

When a socket is closed or shutdown It takes some time for the system to cleanup. I think the linger time is usually a minute or two but it depends on the OS. Agoo sets the SO_REUSEPORT option when it binds to a port which allows it to restart and use the same port immediately. If Puma does not set that option it will not be able to bind until the linger time has elapsed. You might check and see if Ctrl-C on Puma cause the same behaviour when trying to restart Puma.

ohler55 commented 4 years ago

Can this be closed?

tomas commented 4 years ago

Yup, thanks!