flashmob / go-guerrilla

Mini SMTP server written in golang
MIT License
2.79k stars 366 forks source link

Config reloading feature #18

Closed flashmob closed 7 years ago

flashmob commented 8 years ago

Currently working on it. Hope to have the following features when a SIG_HUP is caught:

  1. "allowed hosts" map reloading (need this since we change/add hosts frequently)
  2. Backend switching, ie. detect if backend config changed, close old backend and spawn a new one
  3. detect if SSL cert changed and reload it (useful since letsencrypt certs expire every few months, so our server would need to reload the ssl certs once per day at least)
  4. Listening interface changes. Detect if interface changed. If changed, shutdown old server(s) and start a new one(s) (Not really needed feature, may leave for later)
  5. Close and re-open log files. (Need this for logrotate)

That way the server can continue working without disrupting the hundreds of connections it may have open.

Going to implement it using an event based approach using https://github.com/asaskevich/EventBus

flashmob commented 8 years ago

Since the config can change, another thing to take into account would be thread safety. This should be handy https://golang.org/pkg/sync/atomic/#example_Value_config

flashmob commented 8 years ago

To make it easier, old connections will still use existing config. Subsequent new connections will use the new config.

flashmob commented 8 years ago

First draft https://github.com/flashmob/go-guerrilla/pull/19