ohler55 / agoo

A High Performance HTTP Server for Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Agoo crash and exit

noraj opened this issue · comments

  • Agoo version: 2.15.7
  • Ruby version ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
  • OS : ArchLinux

Commands:

  • Working commands
    • agoo
    • agoo -d /srv/http -b http://127.0.0.2:4242 -p 4242 -w 1 -v
    • agoo --thread 8
  • Crashing commands
    • agoo -d /srv/http -b 127.0.0.2 -p 4242 -t 1 -w 1 -v
  • No crash but directly exiting
    • agoo -d /srv/http -p 4242 -t 1 -w 1 -v
    • agoo -d /srv/http -b http://127.0.0.2:4242 -p 4242 -t 1 -w 1 -v
    • agoo -d /srv/http -b http://127.0.0.2:4242 -t 1 -w 1 -v
    • agoo -t 1
    • agoo --thread 1

AFAIU:

  • agoo crashes (core dump) when a hostname, domain or IP address is given instead of a full URL to the bind parameter.
  • agoo exits when the only one thread is asked.

Reproduce

Crash

Minimal crash: agoo -b 127.0.0.2

agoo-crash.log

Minimal working with bind option: agoo -b http://127.0.0.2:4242

Exit

Minimal exit: agoo -t 1

Minimal working with thread option: agoo -t 2

I'll get it fixed. Might take a week though.

Sorry for the delay. The "in-a-bind" branch has a partial fix. I'm still checking the premature exit cases now in a linux shell as they seem to behave as expected on macOS.

Be aware that attempting to bind to an address that is not configured for the machine will result in an error so 127.0.0.2:4242 should exit with an error. Also using both -b and -p will result in the server listening on two interfaces. Maybe that's what you want though.

Also using both -b and -p will result in the server listening on two interfaces. Maybe that's what you want though.

When using only -b it's still listening on 2 sockets:

➜ agoo -d /srv/http -b http://127.0.0.2:4242 -t 1 -w 1 -v

Agoo 2.15.7 is listening on port 6464. Path mappings are:
Agoo is only serving static files in '/srv/http'.
I 2023/09/27 20:00:04.696123993 INFO: Agoo 2.15.7 with pid 31789 is listening on http://:6464.
I 2023/09/27 20:00:04.696132013 INFO: Agoo 2.15.7 with pid 31789 is listening on http://127.0.0.2:4242.

So I was trying to use -p as well to at least use the same port. Shouldn't the default bind be disabled when -b is used?

Other than that, the issues seem fixed.

Updated to not bind to the default if -b is given.

Okay works from CLI. I read the change to understand how to do that on the lib and it seems to be using 0.

Agoo::Server.init(0, 'root', bind: 'http://localhost:4242')

But it looks it was already documented: https://rubydoc.info/gems/agoo/Agoo/Server#init-class_method

Release v2.15.8 includes the fix.