]> Cypherpunks.ru repositories - gocheese.git/blobdiff - gocheese.go
daemontools friendliness
[gocheese.git] / gocheese.go
index 432fb6f76e1ca0f1468baa9fea2c97814fe4439a..d467bba22209ea413be5cc05f6a68d89c5e8d50f 100644 (file)
@@ -43,7 +43,7 @@ import (
 )
 
 const (
-       Version   = "2.4.1"
+       Version   = "2.5.0"
        HTMLBegin = `<!DOCTYPE html>
 <html>
   <head>
@@ -96,6 +96,7 @@ var (
        gpgUpdateURLPath = flag.String("gpgupdate", "/gpgupdate/", "GPG forceful refreshing URL path")
        pypiURL          = flag.String("pypi", "https://pypi.org/simple/", "Upstream PyPI URL")
        passwdPath       = flag.String("passwd", "passwd", "Path to file with authenticators")
+       logTimestamped   = flag.Bool("log-timestamped", false, "Prepend timestmap to log messages")
        passwdCheck      = flag.Bool("passwd-check", false, "Test the -passwd file for syntax errors and exit")
        fsck             = flag.Bool("fsck", false, "Check integrity of all packages (errors are in stderr)")
        maxClients       = flag.Int("maxclients", 128, "Maximal amount of simultaneous clients")
@@ -264,31 +265,39 @@ func main() {
                return
        }
        if *version {
-               fmt.Println("GoCheese version", Version, "built with", runtime.Version())
+               fmt.Println("GoCheese", Version, "built with", runtime.Version())
                return
        }
+
+       if *logTimestamped {
+               log.SetFlags(log.Ldate | log.Lmicroseconds | log.Lshortfile)
+       } else {
+               log.SetFlags(log.Lshortfile)
+       }
+       log.SetOutput(os.Stdout)
+
        if *fsck {
                if !goodIntegrity() {
                        os.Exit(1)
                }
                return
        }
+
        if *passwdCheck {
                refreshPasswd()
                return
        }
+
        if (*tlsCert != "" && *tlsKey == "") || (*tlsCert == "" && *tlsKey != "") {
                log.Fatalln("Both -tls-cert and -tls-key are required")
        }
+
        var err error
        pypiURLParsed, err = url.Parse(*pypiURL)
        if err != nil {
                log.Fatalln(err)
        }
        refreshPasswd()
-       log.Println("root:", *root)
-       log.Println("bind:", *bind)
-       log.Println("pypi:", *pypiURL)
 
        ln, err := net.Listen("tcp", *bind)
        if err != nil {
@@ -325,6 +334,12 @@ func main() {
                cancel()
        }(server)
 
+       log.Println(
+               "GoCheese", Version, "listens:",
+               "root:", *root,
+               "bind:", *bind,
+               "pypi:", *pypiURL,
+       )
        if *tlsCert == "" {
                err = server.Serve(ln)
        } else {