Reload configuration and restart server when config file changes

Review Request #9568 - Created Feb. 1, 2018 and submitted

Barret Rennie
rb-gateway
master
9565
033637a...
rb-gateway

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.

Barret Rennie
David Trowbridge
  1. Ship It!
  2. 
      
Barret Rennie
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (192a9b8)
Loading...