restinio icon indicating copy to clipboard operation
restinio copied to clipboard

Changing server settings

Open Lord-Kamina opened this issue 5 years ago • 1 comments

Say I have an instance of http_server_t, and most of the server settings are end-user configurable. Is it possible to change said server's settings (Of course I assume I'd need to close the server and open it again), or is it better to just make a new instance with the new settings to replace the old one?

Additionally, in a situation such as described above... what should I do with the io_context? I'm currently using restinio::own_io_context(), do I also need to stop and restart the io_context (I'm thinking yes), would you recommend I keep using restinio::own_io_context() or should I switch to an external io_context?

Lord-Kamina avatar Jun 06 '20 18:06 Lord-Kamina

Is it possible to change said server's settings (Of course I assume I'd need to close the server and open it again), or is it better to just make a new instance with the new settings to replace the old one?

In the current design, the settings are split to several parts and those parts are stored in different objects behind http_server_t instance. And this is performed only at the initialization time (in the constructors of http_server_t and related objects). So you can't change server settings after the creation of http_server_t instance in RESTinio 0.6. You have to recreate the server to apply new settings.

I'm currently using restinio::own_io_context(), do I also need to stop and restart the io_context (I'm thinking yes),

If you recreate http_server_t instance with own_io_contect then io_context will be recreated automatically too. If it is an issue for your usecase (for example, you attach some of your objects to RESTinio's io_context and don't want to lost them) then you have to use external io_context to keep.

eao197 avatar Jun 07 '20 04:06 eao197