Merge pull request #80 from iron-io/stdin

Streams stderr from user functions and outputs a standard format for …
This commit is contained in:
Travis Reeder
2016-08-30 13:57:15 -07:00
committed by GitHub
5 changed files with 45 additions and 8 deletions

View File

@@ -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,
@@ -147,7 +149,7 @@ func handleRunner(c *gin.Context) {
ID: reqID,
AppName: appName,
Stdout: &stdout,
Stderr: &stderr,
Stderr: stderr,
Env: envVars,
}
@@ -162,7 +164,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)
}
}

View File

@@ -7,7 +7,7 @@ import (
)
// Version of IronFunctions
var Version = "0.0.2"
var Version = "0.0.31"
func handleVersion(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"version": Version})