fix: add shutdown signal and flag for renterd
This commit is contained in:
parent
4e6c29f1fd
commit
fb65690abd
10
main.go
10
main.go
|
@ -90,10 +90,16 @@ func main() {
|
|||
app.Get("/swagger/{any:path}", swaggerUI)
|
||||
|
||||
// Start the Iris app and listen for incoming requests on port 80
|
||||
log.Fatal(app.Listen(":8080", func(app *iris.Application) {
|
||||
err := app.Listen(":8080", func(app *iris.Application) {
|
||||
routes := app.GetRoutes()
|
||||
for _, route := range routes {
|
||||
log.Println(route)
|
||||
}
|
||||
}))
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
renterd.ShutdownComplete()
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ var (
|
|||
seed *types.PrivateKey
|
||||
ready = make(chan bool)
|
||||
readyFired = false
|
||||
shutdown = make(chan bool)
|
||||
shutdownFired = false
|
||||
)
|
||||
|
||||
func check(context string, err error) {
|
||||
|
@ -367,6 +369,8 @@ func Main() {
|
|||
log.Fatalf("Shutdown function %v failed: %v", i+1, err)
|
||||
}
|
||||
}
|
||||
|
||||
shutdown <- true
|
||||
}
|
||||
|
||||
func GetApiAddr() string {
|
||||
|
@ -382,3 +386,13 @@ func Ready() bool {
|
|||
|
||||
return true
|
||||
}
|
||||
|
||||
func ShutdownComplete() bool {
|
||||
if shutdownFired {
|
||||
return true
|
||||
}
|
||||
|
||||
shutdownFired = <-shutdown
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue