mirror of https://github.com/dapr/quickstarts.git
fix unsubscribe for go http example
Signed-off-by: Sarthak Sharma <sartsharma@microsoft.com>
This commit is contained in:
parent
e9d3da9dc0
commit
e7cfccf383
|
|
@ -93,20 +93,16 @@ func startServerToListen(subscriptionId *string) {
|
|||
}
|
||||
r.HandleFunc("/configuration/configstore/{configItem}", configUpdateHandler).Methods("POST")
|
||||
|
||||
// Shutdown Server after 20 seconds
|
||||
// Unsubscribe to config updates and shutdown http server after 20 seconds
|
||||
time.AfterFunc(20*time.Second, func() {
|
||||
unsubscribeFromConfigUpdates(*subscriptionId)
|
||||
fmt.Println("Shutting down HTTP server")
|
||||
err := httpServer.Shutdown(context.Background())
|
||||
if err != nil {
|
||||
fmt.Println("Error shutting down HTTP server, err:" + err.Error())
|
||||
}
|
||||
})
|
||||
|
||||
// Register shutdown function
|
||||
httpServer.RegisterOnShutdown(func() {
|
||||
fmt.Println("Shutting down HTTP server")
|
||||
unsubscribeFromConfigUpdates(*subscriptionId)
|
||||
})
|
||||
|
||||
// Start HTTP server
|
||||
if err := httpServer.ListenAndServe(); err != nil {
|
||||
log.Println("HTTP server error:", err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue