Add ability to reload config file for warewulfd on SIGHUP
This commit is contained in:
@@ -3,6 +3,9 @@ package warewulfd
|
|||||||
import (
|
import (
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: https://github.com/danderson/netboot/blob/master/pixiecore/dhcp.go
|
// TODO: https://github.com/danderson/netboot/blob/master/pixiecore/dhcp.go
|
||||||
@@ -10,6 +13,23 @@ import (
|
|||||||
|
|
||||||
func RunServer() error {
|
func RunServer() error {
|
||||||
|
|
||||||
|
c := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(c, syscall.SIGHUP)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for _ = range c {
|
||||||
|
err := LoadNodeDB()
|
||||||
|
if err != nil {
|
||||||
|
wwlog.Printf(wwlog.WARN, "Could not load database: %s\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
err := LoadNodeDB()
|
||||||
|
if err != nil {
|
||||||
|
wwlog.Printf(wwlog.WARN, "Could not load database: %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
wwlog.Printf(wwlog.DEBUG, "Registering handlers for the web service\n")
|
wwlog.Printf(wwlog.DEBUG, "Registering handlers for the web service\n")
|
||||||
|
|
||||||
http.HandleFunc("/ipxe/", IpxeSend)
|
http.HandleFunc("/ipxe/", IpxeSend)
|
||||||
@@ -21,7 +41,11 @@ func RunServer() error {
|
|||||||
|
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Starting HTTPD REST service\n")
|
wwlog.Printf(wwlog.VERBOSE, "Starting HTTPD REST service\n")
|
||||||
|
|
||||||
http.ListenAndServe(":9873", nil)
|
err = http.ListenAndServe(":9873", nil)
|
||||||
|
if err != nil {
|
||||||
|
wwlog.Printf(wwlog.ERROR, "Could not start listening service: %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user