diff options
Diffstat (limited to 'contrib/cgi/gopher.go')
-rw-r--r-- | contrib/cgi/gopher.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/cgi/gopher.go b/contrib/cgi/gopher.go index 67ea688..2f90f22 100644 --- a/contrib/cgi/gopher.go +++ b/contrib/cgi/gopher.go @@ -1,6 +1,7 @@ package cgi import ( + "bytes" "context" "fmt" "os" @@ -11,6 +12,7 @@ import ( sr "tildegit.org/tjp/sliderule" "tildegit.org/tjp/sliderule/gopher" "tildegit.org/tjp/sliderule/gopher/gophermap" + "tildegit.org/tjp/sliderule/logging" ) // GopherCGIDirectory runs any executable files relative to a root directory on the file system. @@ -113,11 +115,17 @@ func runGopherCGI( pathinfo string, settings gophermap.FileSystemSettings, ) *sr.Response { - stdout, exitCode, err := RunCGI(ctx, request, fullpath, pathinfo) + stderr := &bytes.Buffer{} + stdout, exitCode, err := RunCGI(ctx, request, fullpath, pathinfo, stderr) if err != nil { return gopher.Error(err).Response() } if exitCode != 0 { + ctx.Value("warnlog").(logging.Logger).Log( + "msg", "cgi exited with non-zero exit code", + "code", exitCode, + "stderr", stderr.String(), + ) return gopher.Error( fmt.Errorf("CGI process exited with status %d", exitCode), ).Response() |