diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-09-09 08:42:21 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-09-09 08:42:21 -0600 |
commit | 33648cc286e812a8603743c29e96830de3b4acb8 (patch) | |
tree | 2253b0c71035f866fb14e6692baf5587b1925fb4 /contrib/cgi/gemini.go | |
parent | 195bdb565e9cb46e8d88ee364dcfc96a65a7159a (diff) |
log stderr on failed CGIs
Diffstat (limited to 'contrib/cgi/gemini.go')
-rw-r--r-- | contrib/cgi/gemini.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/cgi/gemini.go b/contrib/cgi/gemini.go index d245c8e..1e97939 100644 --- a/contrib/cgi/gemini.go +++ b/contrib/cgi/gemini.go @@ -1,12 +1,14 @@ package cgi import ( + "bytes" "context" "fmt" "strings" sr "tildegit.org/tjp/sliderule" "tildegit.org/tjp/sliderule/gemini" + "tildegit.org/tjp/sliderule/logging" ) // GeminiCGIDirectory runs any executable files relative to a root directory on the file system. @@ -30,11 +32,17 @@ func GeminiCGIDirectory(pathRoot, fsRoot string) sr.Handler { return nil } - stdout, exitCode, err := RunCGI(ctx, request, filepath, pathinfo) + stderr := &bytes.Buffer{} + stdout, exitCode, err := RunCGI(ctx, request, filepath, pathinfo, stderr) if err != nil { return gemini.Failure(err) } if exitCode != 0 { + ctx.Value("warnlog").(logging.Logger).Log( + "msg", "cgi exited with non-zero exit code", + "code", exitCode, + "stderr", stderr.String(), + ) return gemini.CGIError(fmt.Sprintf("CGI process exited with status %d", exitCode)) } |