mirror of
https://github.com/minio/minio.git
synced 2025-11-20 18:06:10 -05:00
Add sighup, sigusr2 into trapping code, to trap signals for reloading configuration.
Need to still figure out a way of graceful restarts - gave facebookgo/httpdown a shot, but it is not suitable.
This commit is contained in:
25
commands.go
25
commands.go
@@ -1,7 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"os/user"
|
||||
"syscall"
|
||||
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/minio/pkg/controller"
|
||||
@@ -67,13 +70,33 @@ func getServerConfig(c *cli.Context) api.Config {
|
||||
}
|
||||
}
|
||||
|
||||
func trapServer(doneCh chan struct{}) {
|
||||
// Go signal notification works by sending `os.Signal`
|
||||
// values on a channel.
|
||||
sigs := make(chan os.Signal, 1)
|
||||
|
||||
// `signal.Notify` registers the given channel to
|
||||
// receive notifications of the specified signals.
|
||||
signal.Notify(sigs, syscall.SIGHUP, syscall.SIGUSR2)
|
||||
|
||||
// This executes a blocking receive for signals.
|
||||
// When it gets one it'll then notify the program
|
||||
// that it can finish.
|
||||
<-sigs
|
||||
doneCh <- struct{}{}
|
||||
}
|
||||
|
||||
func runServer(c *cli.Context) {
|
||||
_, err := user.Current()
|
||||
if err != nil {
|
||||
Fatalf("Unable to determine current user. Reason: %s\n", err)
|
||||
}
|
||||
doneCh := make(chan struct{})
|
||||
go trapServer(doneCh)
|
||||
|
||||
apiServerConfig := getServerConfig(c)
|
||||
if err := server.StartServices(apiServerConfig); err != nil {
|
||||
err = server.StartServices(apiServerConfig, doneCh)
|
||||
if err != nil {
|
||||
Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user