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)
|
app.Get("/swagger/{any:path}", swaggerUI)
|
||||||
|
|
||||||
// Start the Iris app and listen for incoming requests on port 80
|
// 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()
|
routes := app.GetRoutes()
|
||||||
for _, route := range routes {
|
for _, route := range routes {
|
||||||
log.Println(route)
|
log.Println(route)
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
renterd.ShutdownComplete()
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,11 +46,13 @@ var (
|
||||||
builddate = "?"
|
builddate = "?"
|
||||||
|
|
||||||
// fetched once, then cached
|
// fetched once, then cached
|
||||||
apiPassword *string
|
apiPassword *string
|
||||||
apiAddr *string
|
apiAddr *string
|
||||||
seed *types.PrivateKey
|
seed *types.PrivateKey
|
||||||
ready = make(chan bool)
|
ready = make(chan bool)
|
||||||
readyFired = false
|
readyFired = false
|
||||||
|
shutdown = make(chan bool)
|
||||||
|
shutdownFired = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func check(context string, err error) {
|
func check(context string, err error) {
|
||||||
|
@ -367,6 +369,8 @@ func Main() {
|
||||||
log.Fatalf("Shutdown function %v failed: %v", i+1, err)
|
log.Fatalf("Shutdown function %v failed: %v", i+1, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shutdown <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetApiAddr() string {
|
func GetApiAddr() string {
|
||||||
|
@ -382,3 +386,13 @@ func Ready() bool {
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ShutdownComplete() bool {
|
||||||
|
if shutdownFired {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdownFired = <-shutdown
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue