diff options
Diffstat (limited to 'service/http')
-rw-r--r-- | service/http/handler.go | 5 | ||||
-rw-r--r-- | service/http/request.go | 6 | ||||
-rw-r--r-- | service/http/rpc.go | 33 | ||||
-rw-r--r-- | service/http/uploads.go | 3 |
4 files changed, 10 insertions, 37 deletions
diff --git a/service/http/handler.go b/service/http/handler.go index 945cd51e..f719c751 100644 --- a/service/http/handler.go +++ b/service/http/handler.go @@ -72,10 +72,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - if err = req.Open(); err != nil { - h.handleError(w, r, err) - return - } + req.Open() defer req.Close() p, err := req.Payload() diff --git a/service/http/request.go b/service/http/request.go index d733b20c..eb5c05bd 100644 --- a/service/http/request.go +++ b/service/http/request.go @@ -109,12 +109,12 @@ func NewRequest(r *http.Request, cfg *UploadsConfig) (req *Request, err error) { } // Open moves all uploaded files to temporary directory so it can be given to php later. -func (r *Request) Open() error { +func (r *Request) Open() { if r.Uploads == nil { - return nil + return } - return r.Uploads.Open() + r.Uploads.Open() } // Close clears all temp file uploads diff --git a/service/http/rpc.go b/service/http/rpc.go index 9dfe718e..08b3f262 100644 --- a/service/http/rpc.go +++ b/service/http/rpc.go @@ -2,6 +2,7 @@ package http import ( "github.com/pkg/errors" + "github.com/spiral/roadrunner/util" ) type rpcServer struct{ svc *Service } @@ -9,22 +10,7 @@ type rpcServer struct{ svc *Service } // WorkerList contains list of workers. type WorkerList struct { // Workers is list of workers. - Workers []Worker `json:"workers"` -} - -// Worker provides information about specific worker. -type Worker struct { - // Pid contains process id. - Pid int `json:"pid"` - - // Status of the worker. - Status string `json:"status"` - - // Number of worker executions. - NumJobs int64 `json:"numExecs"` - - // Created is unix nano timestamp of worker creation time. - Created int64 `json:"created"` + Workers []*util.State `json:"workers"` } // Reset resets underlying RR worker pool and restarts all of it's workers. @@ -38,20 +24,11 @@ func (rpc *rpcServer) Reset(reset bool, r *string) error { } // Workers returns list of active workers and their stats. -func (rpc *rpcServer) Workers(list bool, r *WorkerList) error { +func (rpc *rpcServer) Workers(list bool, r *WorkerList) (err error) { if rpc.svc == nil || rpc.svc.srv == nil { return errors.New("http server is not running") } - for _, w := range rpc.svc.rr.Workers() { - state := w.State() - r.Workers = append(r.Workers, Worker{ - Pid: *w.Pid, - Status: state.String(), - NumJobs: state.NumExecs(), - Created: w.Created.UnixNano(), - }) - } - - return nil + r.Workers, err = util.ServerState(rpc.svc.rr) + return err } diff --git a/service/http/uploads.go b/service/http/uploads.go index 9b205f00..7610ab28 100644 --- a/service/http/uploads.go +++ b/service/http/uploads.go @@ -45,7 +45,7 @@ func (u *Uploads) MarshalJSON() ([]byte, error) { // Open moves all uploaded files to temp directory, return error in case of issue with temp directory. File errors // will be handled individually. -func (u *Uploads) Open() error { +func (u *Uploads) Open() { var wg sync.WaitGroup for _, f := range u.list { wg.Add(1) @@ -56,7 +56,6 @@ func (u *Uploads) Open() error { } wg.Wait() - return nil } // Clear deletes all temporary files. |