Closed MoSal closed 1 week ago
@MoSal Thanks! SIGHUB doesn't look like it's for reloading. Do you just want to reload automatically?
For configuration updates, I would prefer to modify the following cfg.
https://github.com/mokeyish/smartdns-rs/blob/155b5b3a9ee6a0ada34322a72e676c74264a87aa/src/app.rs#L27
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.
@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:
From man 8 sshd
sshd can be configured using command-line options or a configuration file (by default sshd_config(5)); command-line options override values specified in the configuration file. sshd rereads its configuration file when it receives a hangup signal, SIGHUP, by executing itself with the name and options it was started with, e.g. /usr/sbin/sshd.
From man 8 openvpn
SIGHUP Cause OpenVPN to close all TUN/TAP and network connections, restart, re-read the configuration file (if any), and re‐open TUN/TAP and network connections.
I considered looking at RuntimeConfig
, but doing a full App
restart is more in line with the expected behavior from SIGHUP
.
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.
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.
Handle SIGHUP signal, and restart app upon receiving it.
This allows reloading the app with updated configuration without restarting the process.