Reload configuration and restart server when config file changes

Review Request #9568 — Created Feb. 1, 2018 and submitted — Latest diff uploaded

Information

rb-gateway
master
033637a...

Reviewers

We now monitor the config file path with fsnotify to see when it
changes. When we get any event or receive the SIGHUP signal, we reload
the configuration and restart the server. This is possible since Golang
1.8 added the ability to stop a http.Server gracefully.

We also gracefully shut down the server upon receipt of a SIGINT and a
second SIGINT received before graceful shutdown will force-quit the
server.

Ran unit tests.

Tested that the following resulted in configuration being reloaded:

  • touch config.json
  • editing config.json
  • rm config.json (results in server crash since there is no
    configuration to reload)
  • killall -HUP rb-gateway

In the cases where the server should restart, it did on the correct
port.