func init() { flag.IntVar(&WebPort, "web-port", 8080, "Port to bind to") flag.StringVar(&EndPointURL, "endpoint", "http://*****:*****@getfishtank.ca", "SMTP username") flag.StringVar(&SmtpPassword, "smtp-password", "", "SMTP password") flag.StringVar(&DatabaseStore, "database", "mongodb://127.0.0.1:27017/model", "database") flag.StringVar(&GplusKey, "gplus-key", "1049113770955-agedcvcoi68qlbc9mm321odb5qdqlgrg.apps.googleusercontent.com", "Google+ OAuth Key") flag.StringVar(&GplusSecret, "gplus-secret", "TjdRDltddkFtlx9dyStuaa5w", "Google+ OAuth Secret") flag.StringVar(&FacebookKey, "facebook-key", "1667094910175363", "facebook key") flag.StringVar(&FacebookSecret, "facebook-secret", "63472dc2deb3269d298f529cc727b9f2", "facebook secret") flag.StringVar(&TwitterKey, "twitter-key", "QVO8QAPqpvnfX6CY3291GkauQ", "twitter key") flag.StringVar(&TwitterSecret, "twitter-secret", "YpaY8TsSR2aLOJh4o9XIqXSgtRubhACmRI2oWTPJs608hdJYv9", "twitter secret") flag.Parse() log.Printf("Config file %s", config) log.Printf("Web folder %s", StaticAssets) log.Printf("Web host %s", WebHost) log.Printf("Web port %s", WebPort) log.Printf("End point %s", EndPointURL) log.Printf("Use SSL %s", UseSSL) log.Printf("certification file %s", CertFile) log.Printf("key file %s", KeyFile) log.Printf("run folder %s", RunFolder) log.Printf("template folder %s", TemplateFolder) log.Printf("end point %s", EndPointURL) log.Printf("SMTP host %s", SmtpHost) log.Printf("SMTP port %s", SmtpPort) log.Printf("SMTP username %s", SmtpUsername) log.Printf("SMTP password %s", SmtpPassword) log.Printf("Database %s", DatabaseStore) log.Printf("JWT File %s", JwtFile) log.Printf("Google plus %s", GplusKey) log.Printf("Google Secret %s", GplusSecret) log.Printf("facebook %s", FacebookKey) log.Printf("facebook secret %s", FacebookSecret) log.Printf("twitter %s", TwitterKey) log.Printf("twitter secret %s", TwitterSecret) }
func init() { flag.StringVar(&host, "host", "127.0.0.1", "host to bind to") flag.IntVar(&port, "port", 2121, "port to bind to") flag.StringVar(&username, "ftp-username", "ftp2s3", "FTP username") flag.StringVar(&password, "ftp-password", "ftp2s3", "FTP password") flag.StringVar(&serverName, "ftp-server-name", "FTP2S3", "FTP server name") flag.StringVar(&awsRegion, "aws-region", "us-east-1", "AWS region") flag.StringVar(&awsAccessKeyID, "aws-access-key-id", "", "AWS access key ID") flag.StringVar(&awsSecretAccessKey, "aws-secret-access-key", "", "AWS secret access key") flag.StringVar(&awsBucketName, "aws-bucket-name", "", "S3 bucket name") flag.String("config", "", "path to config file") flag.Parse() }
func main() { var ( config string length float64 age int name string female bool ) flag.StringVar(&config, "config", "", "help message") flag.StringVar(&name, "name", "", "help message") flag.IntVar(&age, "age", 0, "help message") flag.Float64Var(&length, "length", 0, "help message") flag.BoolVar(&female, "female", false, "help message") flag.Parse() fmt.Println("length:", length) fmt.Println("age:", age) fmt.Println("name:", name) fmt.Println("female:", female) }
func main() { var ( port = 3001 redisDatabase = 0 redisPoolSize = 10 clientID = "" clientSecret = "" hashKey = "randomishstringthatsi32charslong" blockKey = "randomishstringthatsi32charslong" deferPanicKey = "" ) flag.IntVar(&port, "port", port, "Port to start the server on") flag.IntVar(&procs, "procs", 1, "Number of CPU processors (0 to use max)") flag.BoolVar(&debug, "debug", false, "Debug mode") flag.StringVar( &redisURL, "redisURL", redisURL, "Redis URL to tcp connect to") flag.StringVar( &staticPrefix, "staticPrefix", staticPrefix, "Prefix in front of static assets in HTML") flag.IntVar(&redisDatabase, "redisDatabase", redisDatabase, "Redis database number to connect to") flag.StringVar( &clientID, "clientID", clientID, "OAuth Client ID") flag.StringVar( &clientSecret, "clientSecret", clientSecret, "OAuth Client Secret") flag.BoolVar(&usingHTTPS, "usingHTTPS", usingHTTPS, "Whether requests are made under HTTPS") flag.StringVar( &hashKey, "hashKey", hashKey, "HMAC hash key to use for encoding cookies") flag.StringVar( &blockKey, "blockKey", blockKey, "Block key to encrypt cookie values") flag.StringVar( &deferPanicKey, "deferPanicKey", deferPanicKey, "Auth key for deferpanic.com") flag.Parse() dfs := deferstats.NewClient(deferPanicKey) if deferPanicKey == "" { dfs.SetnoPost(true) } go dfs.CaptureStats() oauthConf.ClientID = clientID oauthConf.ClientSecret = clientSecret sCookie = securecookie.New([]byte(hashKey), []byte(blockKey)) log.Println("REDIS DATABASE:", redisDatabase) log.Println("DEBUG MODE:", debug) log.Println("STATIC PREFIX:", staticPrefix) if !debug { redisPoolSize = 100 } // Figuring out how many processors to use. maxProcs := runtime.NumCPU() if procs == 0 { procs = maxProcs } else if procs < 0 { panic("PROCS < 0") } else if procs > maxProcs { panic(fmt.Sprintf("PROCS > max (%v)", maxProcs)) } log.Println("PROCS:", procs) runtime.GOMAXPROCS(procs) renderer = render.New(render.Options{ IndentJSON: debug, IsDevelopment: debug, }) df := func(network, addr string) (*redis.Client, error) { client, err := redis.Dial(network, addr) if err != nil { return nil, err } err = client.Cmd("SELECT", redisDatabase).Err if err != nil { return nil, err } // if err = client.Cmd("AUTH", "SUPERSECRET").Err; err != nil { // client.Close() // return nil, err // } return client, nil } var err error redisPool, err = pool.NewCustomPool("tcp", redisURL, redisPoolSize, df) errorHandler(err) mux := mux.NewRouter() mux.HandleFunc("/", dfs.HTTPHandler(indexHandler)).Methods("GET", "HEAD") mux.HandleFunc("/v1/ping", dfs.HTTPHandler(pingHandler)).Methods("GET", "HEAD") mux.HandleFunc("/v1", dfs.HTTPHandler(fetchHandler)).Methods("GET", "HEAD") mux.HandleFunc("/v1", dfs.HTTPHandler(updateHandler)).Methods("POST", "PUT") mux.HandleFunc("/v1", dfs.HTTPHandler(deleteHandler)).Methods("DELETE") mux.HandleFunc("/v1/stats", dfs.HTTPHandler(privateStatsHandler)).Methods("GET") mux.HandleFunc("/v1/flush", dfs.HTTPHandler(flushHandler)).Methods("DELETE") mux.HandleFunc("/v1/bulk", dfs.HTTPHandler(bulkHandler)).Methods("POST", "PUT") mux.HandleFunc("/login", dfs.HTTPHandler(handleGitHubLogin)).Methods("GET") mux.HandleFunc("/logout", dfs.HTTPHandler(logoutHandler)).Methods("GET", "POST") mux.HandleFunc("/github_oauth_cb", dfs.HTTPHandler(handleGitHubCallback)).Methods("GET") mux.HandleFunc("/domainkeys/new", domainkeyNewHandler).Methods("POST") mux.HandleFunc("/domainkeys/delete", domainkeyDeleteHandler).Methods("POST") n := negroni.Classic() n.UseHandler(mux) n.Run(fmt.Sprintf(":%d", port)) }
func init() { flag.StringVar(&crontabPath, "file", "crontab", "crontab file path") flag.IntVar(&numCPU, "cpu", runtime.NumCPU(), "maximum number of CPUs") }