summaryrefslogtreecommitdiff
path: root/service/http/service.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-13 20:49:26 +0300
committerWolfy-J <[email protected]>2018-06-13 20:49:26 +0300
commitfba45ff53a51bf173471e6d046fc46f0cbaf89e3 (patch)
tree0855eda2eb334d4d4f26157438649e0f58151f9d /service/http/service.go
parent87fff670cc5a446f4c396c30d330ce7958e9f40f (diff)
http service test + status test
Diffstat (limited to 'service/http/service.go')
-rw-r--r--service/http/service.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/service/http/service.go b/service/http/service.go
index 881c862d..2b30cd1c 100644
--- a/service/http/service.go
+++ b/service/http/service.go
@@ -6,6 +6,7 @@ import (
"context"
"github.com/spiral/roadrunner"
"github.com/spiral/roadrunner/service/rpc"
+ "sync"
)
// Name contains default svc name.
@@ -18,8 +19,10 @@ type middleware func(w http.ResponseWriter, r *http.Request) bool
type Service struct {
cfg *Config
lsns []func(event int, ctx interface{})
- rr *roadrunner.Server
mdws []middleware
+
+ mu sync.Mutex
+ rr *roadrunner.Server
srv *Handler
http *http.Server
}
@@ -63,6 +66,7 @@ func (s *Service) Init(cfg service.Config, c service.Container) (bool, error) {
// Serve serves the svc.
func (s *Service) Serve() error {
+ s.mu.Lock()
rr := roadrunner.NewServer(s.cfg.Workers)
s.rr = rr
@@ -77,6 +81,7 @@ func (s *Service) Serve() error {
} else {
s.http.Handler = s
}
+ s.mu.Unlock()
if err := rr.Start(); err != nil {
return err
@@ -92,6 +97,8 @@ func (s *Service) Serve() error {
// Stop stops the svc.
func (s *Service) Stop() {
+ s.mu.Lock()
+ defer s.mu.Unlock()
if s.http == nil {
return
}