ostinelli / misultin

Misultin (pronounced mee-sool-téen) is an Erlang library for building fast lightweight HTTP(S) servers, which also supports websockets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use timeout in gen_tcp:accept

knutin opened this issue · comments

Hi,

It would be very useful to have misultin_socket:accept/2 timeout after a few seconds if it does not accept anything, as it would allow smoother code upgrades. When it timeouts, it should re-enter the same loop with a fully qualified module name so it gets the new code. This lets us avoid killing processes to force them to get the new code and not loose any requests.

thank you for this suggestion. still not comfortable in timing these out. any system hooks you are aware of that could be used for callbacks instead?

Do you mean callbacks for reloading? If you are using gen-based servers and releases, there is the code_change callback, but as the process is waiting on accept/2 it is blocking these calls.

The only way I can think of is to timeout and loop. May I ask why you are uncomfortable with the timeouts?

no particular reason. i'd prefer though to have somewhat these processes reloaded on a code_change, unfortunately they depend on a supervisor which hasn't such a callback. that's why i asked for (maybe) system callbacks.

if i can't find anything else, i'll take your suggestion and implement it asap.

thank you,

r.

closed, 65952fa

please let me know if this solves your needs.

thank you,

r.

unfortunately this does not work. somehow, causing the acceptors to timeout and forcing code reload actually makes the supervisors restart the acceptors. obviously, after the 5th time the supervisors have to do this, they take down misultin as a whole.

took this away for now. if you feel like digging into it, let me know 596bb33

thank you,

r.

only thing that i can do to make it properly work for now is committed on 66ef7c1

if you need you need more than that, do not hesitate to let me know and discuss how to implement this.

thank you,

r.