--- a/README.md Mon Mar 07 02:08:55 2022 -0600
+++ b/README.md Mon Mar 07 02:11:52 2022 -0600
@@ -84,18 +84,18 @@
The `serve` command is the main mode of operation which is to provide access to
-You can optionally disable either one of the HTTP or SSH servers to limit
+You can optionally disable either one of the HGWeb or SSH servers to limit resources or just disable the portions you don't need.
For example, say you don't need public access or the web interface at all, you
-can disable it by passing `--disable-http` to the `serve` command or by setting
-the `HGK_DISABLE_HTTP` environment variable to `true`.
+can disable it by passing `--disable-hgweb` to the `serve` command or by setting +the `HGK_DISABLE_HGWEB` environment variable to `true`. Likewise, if you just want to serve up read only repositories over http you can
disable the SSH server by passing `--disable-ssh` to the `serve` command or by
setting the `HGK_DISABLE_SSH` environment variable to `true`.
-The `--disable-http` and `--disable-ssh` options are mutually exclusive and
+The `--disable-hgweb` and `--disable-ssh` options are mutually exclusive and passing both will stop HGKeeper from starting.
The `serve` command also has options to tell HGKeeper how it can be accessed
--- a/http/server.go Mon Mar 07 02:08:55 2022 -0600
+++ b/http/server.go Mon Mar 07 02:11:52 2022 -0600
@@ -19,16 +19,21 @@
-func NewServer(listenAddr string, externalHostname, externalPort string) (*Server, error) {
+func NewServer(listenAddr string, disableHGWeb bool, externalHostname, externalPort string) (*Server, error) {
externalHostname: externalHostname,
externalPort: externalPort,
func (s *Server) Listen() error {
@@ -51,11 +56,16 @@
mux.Handle("/static/", http.StripPrefix("/static", fileServer))
- hgwHandler, err := s.hgw.Handler()
+ log.Infof("enabling HGWeb CGI server") + hgwHandler, err := s.hgw.Handler() + mux.Handle("/", hgwHandler) + log.Infof("not enabling HGWeb CGI server as requested") - mux.Handle("/", hgwHandler)
s.server.Handler = Logger(mux)
@@ -65,8 +75,10 @@
func (s *Server) Close() {
- if err := s.hgw.Close(); err != nil {
- log.Warnf("failed to close hgweb: %v", err)
+ if err := s.hgw.Close(); err != nil { + log.Warnf("failed to close hgweb: %v", err) if err := s.server.Close(); err != nil {
--- a/serve/command.go Mon Mar 07 02:08:55 2022 -0600
+++ b/serve/command.go Mon Mar 07 02:11:52 2022 -0600
@@ -19,14 +19,14 @@
SSHHostKeysPath string `kong:"flag,name='ssh-host-keys-path',env='HGK_SSH_HOST_KEYS_PATH',short='H',help='the path where host keys are kept',default='host-keys'"`
HTTPAddr string `kong:"flag,name='http-listen-addr',env='HGK_HTTP_LISTEN_ADDR',help='what address the http server listens on',default=':8080'"`
DisableSSH bool `kong:"flag,name='disable-ssh',env='HGK_DISABLE_SSH',help='disable the SSH server',default='false'"`
- DisableHTTP bool `kong:"flag,name='disable-http',env='HGK_DISABLE_HTTP',help='disable the HTTP server',default='false'"`
+ DisableHGWeb bool `kong:"flag,name='disable-hgweb',env='HGK_DISABLE_HGWEB',help='disable the HGWEB cgi server',default='false'"` ExternalHostname string `kong:"flag,name='external-hostname',env='HGK_EXTERNAL_HOSTNAME',help='The external hostname of the hgkeeper instance. This is used to integrate with other ssh servers.'"`
ExternalPort string `kong:"flag,name='external-port',env='HGK_EXTERNAL_PORT',help='The external port of the hgkeeper instance. This is used to itegrate with other ssh servers.',default='22222'"`
func (c *Command) Run(g *globals.Globals) error {
- if c.DisableHTTP && c.DisableSSH {
- return fmt.Errorf("both HTTP and SSH servers have been disabled")
+ if c.DisableHGWeb && c.DisableSSH { + return fmt.Errorf("both HGWeb and SSH servers have been disabled") if err := access.Setup(g.ReposPath, g.AdminRepo); err != nil {
@@ -40,7 +40,6 @@
errChan := make(chan error, 10)
var sshServer *ssh.Server
- var httpServer *http.Server
log.Info("SSH server has been disabled")
@@ -53,16 +52,11 @@
- log.Info("HTTP server has been disabled")
- httpServer, err = http.NewServer(c.HTTPAddr, c.ExternalHostname, c.ExternalPort)
- defer httpServer.Close()
+ httpServer, err := http.NewServer(c.HTTPAddr, c.DisableHGWeb, c.ExternalHostname, c.ExternalPort) + defer httpServer.Close() @@ -72,13 +66,11 @@
- if err := httpServer.Listen(); err != nil {
+ if err := httpServer.Listen(); err != nil {