diff options
author | Wolfy-J <[email protected]> | 2018-06-12 19:06:01 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-12 19:06:01 +0300 |
commit | f8d8e9a55d31c6ee98b1f292e49b31b474883a4f (patch) | |
tree | a931e304869d1076b5ca6bd793800d701406331a /service | |
parent | d6aa174084bff228ab36d560252e2d11d0d6cc15 (diff) |
tests!
Diffstat (limited to 'service')
-rw-r--r-- | service/http/server.go | 10 | ||||
-rw-r--r-- | service/http/service.go | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/service/http/server.go b/service/http/server.go index 4ac9b03c..cad2e46d 100644 --- a/service/http/server.go +++ b/service/http/server.go @@ -8,15 +8,15 @@ import ( ) const ( - // EventResponse thrown after the request been processed. See Log as payload. + // EventResponse thrown after the request been processed. See Event as payload. EventResponse = iota + 500 // EventError thrown on any non job error provided by road runner server. EventError ) -// Log represents singular http response event. -type Log struct { +// Event represents singular http response event. +type Event struct { // Method of the request. Method string @@ -94,12 +94,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { // handleResponse triggers response event. func (s *Server) handleResponse(req *Request, resp *Response) { - s.throw(EventResponse, &Log{Method: req.Method, Uri: req.Uri, Status: resp.Status}) + s.throw(EventResponse, &Event{Method: req.Method, Uri: req.Uri, Status: resp.Status}) } // handleError sends error. func (s *Server) handleError(w http.ResponseWriter, r *http.Request, err error) { - s.throw(EventError, &Log{Method: r.Method, Uri: uri(r), Status: 500, Error: err}) + s.throw(EventError, &Event{Method: r.Method, Uri: uri(r), Status: 500, Error: err}) w.WriteHeader(500) w.Write([]byte(err.Error())) diff --git a/service/http/service.go b/service/http/service.go index 4187e55a..40eec579 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -118,6 +118,9 @@ func (s *Service) listener(event int, ctx interface{}) { } if event == roadrunner.EventServerFailure { - s.Stop() + // attempting rr server restart + if err := s.rr.Start(); err != nil { + s.Stop() + } } } |