mokeyish / smartdns-rs

A cross platform local DNS server (Dnsmasq like) written in rust to obtain the fastest website IP for the best Internet experience, supports DoT, DoQ, DoH, DoH3.
GNU General Public License v3.0
520 stars 35 forks source link

Restart app upon receiving SIGHUP signal #331

Closed MoSal closed 1 week ago

MoSal commented 2 weeks ago

Handle SIGHUP signal, and restart app upon receiving it.

This allows reloading the app with updated configuration without restarting the process.

mokeyish commented 2 weeks ago

@MoSal Thanks! SIGHUB doesn't look like it's for reloading. Do you just want to reload automatically?

mokeyish commented 2 weeks ago

For configuration updates, I would prefer to modify the following cfg.

https://github.com/mokeyish/smartdns-rs/blob/155b5b3a9ee6a0ada34322a72e676c74264a87aa/src/app.rs#L27

mokeyish commented 2 weeks ago

If it is just to trigger a reload, is it possible to use HTTP POST? The design is that it can be controlled by HTTP (adding a web dashboard), but due to being busy at work, there has been no progress.

https://github.com/mokeyish/smartdns-rs/blob/155b5b3a9ee6a0ada34322a72e676c74264a87aa/src/api/cache.rs#L17

MoSal commented 2 weeks ago

@MoSal Thanks! SIGHUB doesn't look like it's for reloading. Do you just want to reload automatically?

Modern usage of SIGHUP is for full reloads.

Here are two examples:

I considered looking at RuntimeConfig, but doing a full App restart is more in line with the expected behavior from SIGHUP.

mokeyish commented 2 weeks ago

The cfg is planned to be modifiable via HTTP, adding upstream servers, clearing caches, etc. So, one is to watch configuration file changes, and the other is to receive SIGHUB and then reload. In this case, keep main::terminate() unchanged, receive SIGHUB inside the app, and update cfg.

MoSal commented 1 week ago

Apologies. But I faced a couple of issues (proto/timeout errors) and had to stop using smartdns-rs because I don't have the time to debug.

Closing.