Skip to content

Commit

Permalink
update api reload
Browse files Browse the repository at this point in the history
  • Loading branch information
kubemq committed Sep 28, 2020
1 parent 43d4a4d commit 0a6bf6b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
9 changes: 6 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: '2'

vars:
BINARY_NAME: kubemq-bridges
VERSION: v0.1.5
VERSION: v0.1.6

tasks:
check_update:
Expand All @@ -29,11 +29,14 @@ tasks:
- go mod vendor
- docker build --build-arg VERSION={{.VERSION}} . -t kubemq/{{.BINARY_NAME}}:{{.VERSION}}
- docker tag kubemq/{{.BINARY_NAME}}:{{.VERSION}} kubemq/{{.BINARY_NAME}}:latest
push:
cmds:
- docker push kubemq/{{.BINARY_NAME}}:{{.VERSION}}
- docker push kubemq/{{.BINARY_NAME}}:latest
release:
cmds:
- task: lint
- git tag -a {{.VERSION}} -m {{.VERSION}}
- git push origin master --tags
- task: docker
- docker push kubemq/{{.BINARY_NAME}}:{{.VERSION}}
- docker push kubemq/{{.BINARY_NAME}}:latest
- task: push
4 changes: 2 additions & 2 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func Start(ctx context.Context, port int, bs *binding.Service) (*Server, error)
}
}

func (s *Server) Stop() {
func (s *Server) Stop() error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
_ = s.echoWebServer.Shutdown(ctx)
return s.echoWebServer.Shutdown(ctx)
}
17 changes: 14 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,24 @@ func run() error {
log.Errorf("error on restarting service with new config file: %s", err.Error())
continue
}
case <-gracefulShutdown:
if apiServer != nil {
err = apiServer.Stop()
if err != nil {
log.Errorf("error on shutdown api server: %s", err.Error())
continue
}
}

apiServer.Stop()
apiServer, err = api.Start(ctx, newConfig.ApiPort, bindingsService)
if err != nil {
log.Errorf("error on start api server: %s", err.Error())
continue
}
case <-gracefulShutdown:
_=apiServer.Stop()
bindingsService.Stop()
return nil
}

}

}
Expand Down

0 comments on commit 0a6bf6b

Please sign in to comment.