Skip to content
Snippets Groups Projects
Commit eabe9f65 authored by Bruce Flynn's avatar Bruce Flynn
Browse files

only open dev/null once to try to fix "too many open files"

parent 3452e11e
Branches main
No related tags found
No related merge requests found
Pipeline #31714 canceled with stage
......@@ -3,9 +3,8 @@ module gitlab.ssec.wisc.edu/brucef/chart-server
go 1.12
require (
github.com/gorilla/context v1.1.1
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/handlers v1.4.0
github.com/gorilla/mux v1.6.2
github.com/pkg/errors v0.8.0
github.com/spf13/pflag v1.0.2
)
......@@ -12,10 +12,19 @@ import (
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/spf13/pflag"
)
var devnull *os.File
func init() {
f, err := os.OpenFile(os.DevNull, 0, 0)
if err != nil {
panic(fmt.Sprintf("unable to open %s: %s", os.DevNull, err))
}
devnull = f
}
func httpFail(w http.ResponseWriter, r *http.Request, msg string, err error) {
log.Printf("InternalServerError: %s: %s: %s", msg, err, r.URL)
http.Error(w, msg, http.StatusInternalServerError)
......@@ -24,9 +33,10 @@ func httpFail(w http.ResponseWriter, r *http.Request, msg string, err error) {
func updateIndex(url, dir string) error {
cmd := exec.Command("helm", "repo", "index", "--url", url, dir)
cmd.Stderr = os.Stderr
cmd.Stdout = devnull
err := cmd.Run()
if err != nil {
return errors.Wrapf(err, "running helm")
return fmt.Errorf("running helm: %w", err)
}
return nil
}
......@@ -79,7 +89,7 @@ var (
)
func main() {
pflag.ErrHelp = errors.New("")
pflag.ErrHelp = fmt.Errorf("")
pflag.Usage = func() {
fmt.Fprintf(os.Stderr, `USAGE %s [options]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment