X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b161916d6b97e8b7205670ecc972a590749dd93c..b53513423ab948804425424278ac554870864997:/cmd/arvados-server/cmd.go diff --git a/cmd/arvados-server/cmd.go b/cmd/arvados-server/cmd.go index 13b06d6795..26c3f485ea 100644 --- a/cmd/arvados-server/cmd.go +++ b/cmd/arvados-server/cmd.go @@ -5,6 +5,10 @@ package main import ( + "encoding/json" + "fmt" + "io" + "net/http" "os" "git.arvados.org/arvados.git/lib/boot" @@ -42,6 +46,7 @@ var ( "keepproxy": keepproxy.Command, "keepstore": keepstore.Command, "recover-collection": recovercollection.Command, + "workbench2": wb2command{}, "ws": ws.Command, }) ) @@ -49,3 +54,31 @@ var ( func main() { os.Exit(handler.RunCommand(os.Args[0], os.Args[1:], os.Stdin, os.Stdout, os.Stderr)) } + +type wb2command struct{} + +func (wb2command) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int { + if len(args) != 3 { + fmt.Fprintf(stderr, "usage: %s api-host listen-addr app-dir\n", prog) + return 1 + } + configJSON, err := json.Marshal(map[string]string{"API_HOST": args[0]}) + if err != nil { + fmt.Fprintf(stderr, "json.Marshal: %s\n", err) + return 1 + } + mux := http.NewServeMux() + mux.Handle("/", http.FileServer(http.Dir(args[2]))) + mux.HandleFunc("/config.json", func(w http.ResponseWriter, _ *http.Request) { + w.Write(configJSON) + }) + mux.HandleFunc("/_health/ping", func(w http.ResponseWriter, _ *http.Request) { + io.WriteString(w, `{"health":"OK"}`) + }) + err = http.ListenAndServe(args[1], mux) + if err != nil { + fmt.Fprintln(stderr, err.Error()) + return 1 + } + return 0 +}