Add http handler option
This commit is contained in:
parent
720753a200
commit
4df44b1fcf
|
|
@ -25,6 +25,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
|
@ -93,6 +95,9 @@ var flCookieFile = flag.Bool("cookie-file", envBool("GIT_COOKIE_FILE", false),
|
||||||
var flGitCmd = flag.String("git", envString("GIT_SYNC_GIT", "git"),
|
var flGitCmd = flag.String("git", envString("GIT_SYNC_GIT", "git"),
|
||||||
"the git command to run (subject to PATH search)")
|
"the git command to run (subject to PATH search)")
|
||||||
|
|
||||||
|
var flHTTPBind = flag.String("http-bind", envString("GIT_SYNC_HTTP_BIND", ""),
|
||||||
|
"the bind address for git-sync's HTTP endpoint")
|
||||||
|
|
||||||
var log = newLoggerOrDie()
|
var log = newLoggerOrDie()
|
||||||
|
|
||||||
func newLoggerOrDie() logr.Logger {
|
func newLoggerOrDie() logr.Logger {
|
||||||
|
|
@ -208,6 +213,17 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *flHTTPBind != "" {
|
||||||
|
ln, err := net.Listen("tcp", *flHTTPBind)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "ERROR: unable to bind HTTP endpoint: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
http.Serve(ln, http.DefaultServeMux)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// From here on, output goes through logging.
|
// From here on, output goes through logging.
|
||||||
log.V(0).Infof("starting up: %q", os.Args)
|
log.V(0).Infof("starting up: %q", os.Args)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue