httpbeast: option to set reusePort#47
Conversation
fd126cf to
303e30c
Compare
dom96
left a comment
There was a problem hiding this comment.
I guess we are relying on the OS complaining about a port being reused without reusePort enabled? Can we add a nicer error message for that case?
src/httpbeast.nim
Outdated
| # processes bind to same address/port. We use an Option to avoid | ||
| # breaking code that relies on `Settings(port: port)` |
There was a problem hiding this comment.
hm, I think we can live with this breakage. initSettings should be used anyway.
There was a problem hiding this comment.
it's in the wild though... in fact, 1st version of this didn't use an Option and it broke some code. Other than that, i agree that initSettings should be used.
note that the recommended way (initSettings) remains clean (no Option used there), so if anything, this is an implementation detail.
yes, I can make a separate PR to add context info (in particular port) in std/net.bindAddr; this can be done independently of this PR (the change belongs in stdlib) To add more context to this PR, jester.newSettings sets before PR:suppose some service already runs in port 5000 (that you may be unaware of, or that might bind right before you launch your new service); then your run: after PR:it now honors it's easy to see by runnning future workI'd recommend changing the default in httpbeast too (matching the default in jester which is saner): (i can do this in this PR too but it'd be a breaking change so i'd recommend doing it in another PR instead; at least now, users have a choice) |
a29b94f to
e08209b
Compare
|
@dom96 PTAL raising when numThreads>1 and reusePort = false just causes more complications, so see PR for what I did instead. |
Squashed commit of the following: commit 43ee8c3 Author: Dominik Picheta <dominikpicheta@gmail.com> Date: Fri Jul 2 21:50:46 2021 +0100 Fix `run`. commit 804d42c Author: Dominik Picheta <dominikpicheta@googlemail.com> Date: Fri Jul 2 21:42:03 2021 +0100 Update src/httpbeast.nim commit eca38f9 Author: Dominik Picheta <dominikpicheta@googlemail.com> Date: Fri Jul 2 21:40:22 2021 +0100 Update src/httpbeast.nim commit c316b87 Author: Dominik Picheta <dominikpicheta@googlemail.com> Date: Fri Jul 2 21:36:33 2021 +0100 Apply suggestions from code review commit e08209b Author: Timothee Cour <timothee.cour2@gmail.com> Date: Thu Jul 1 17:02:43 2021 -0700 ignore reusePort when running with multiple threads for now commit 64310f4 Author: Timothee Cour <timothee.cour2@gmail.com> Date: Sun Jun 27 15:42:52 2021 -0700 fix tests (use an Option to make code backward compatible) commit d6564d0 Author: Timothee Cour <timothee.cour2@gmail.com> Date: Sun Jun 27 14:52:39 2021 -0700 bump version commit 39b93cf Author: Timothee Cour <timothee.cour2@gmail.com> Date: Wed Apr 17 10:09:08 2019 -0700 httpbeast: option to set reusePort
|
Sorry, I prefer for this stuff to be explicit. So I changed things. |
/cc @dom96
the next PR (dom96/jester#278) will allow using this in jester