mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Streams stderr from user functions and outputs a standard format for parsing. See #76.
This commit is contained in:
@@ -112,7 +112,9 @@ func handleRunner(c *gin.Context) {
|
||||
log.WithField("routes", routes).Debug("Got routes from datastore")
|
||||
for _, el := range routes {
|
||||
if params, match := matchRoute(el.Path, route); match {
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
||||
var stdout bytes.Buffer // TODO: should limit the size of this, error if gets too big. akin to: https://golang.org/pkg/io/#LimitReader
|
||||
stderr := runner.NewFuncLogger(appName, route, el.Image, reqID)
|
||||
|
||||
envVars := map[string]string{
|
||||
"METHOD": c.Request.Method,
|
||||
@@ -142,7 +144,7 @@ func handleRunner(c *gin.Context) {
|
||||
ID: reqID,
|
||||
AppName: appName,
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
Stderr: stderr,
|
||||
Env: envVars,
|
||||
}
|
||||
|
||||
@@ -157,7 +159,7 @@ func handleRunner(c *gin.Context) {
|
||||
if result.Status() == "success" {
|
||||
c.Data(http.StatusOK, "", stdout.Bytes())
|
||||
} else {
|
||||
log.WithFields(logrus.Fields{"app": appName, "route": el, "req_id": reqID}).Debug(stderr.String())
|
||||
// log.WithFields(logrus.Fields{"app": appName, "route": el, "req_id": reqID}).Debug(stderr.String())
|
||||
c.AbortWithStatus(http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user