diff options
-rw-r--r-- | cmd/rr/debug/listener.go | 4 | ||||
-rw-r--r-- | service/http/server.go | 10 | ||||
-rw-r--r-- | service/http/service.go | 5 |
3 files changed, 11 insertions, 8 deletions
diff --git a/cmd/rr/debug/listener.go b/cmd/rr/debug/listener.go index 393e2b2e..1b6fcf83 100644 --- a/cmd/rr/debug/listener.go +++ b/cmd/rr/debug/listener.go @@ -20,10 +20,10 @@ func (s *listener) Listener(event int, ctx interface{}) { // http events switch event { case http.EventResponse: - log := ctx.(*http.Log) + log := ctx.(*http.Event) s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.Uri)) case http.EventError: - log := ctx.(*http.Log) + log := ctx.(*http.Event) if _, ok := log.Error.(roadrunner.JobError); ok { s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.Uri)) 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() + } } } |