func main() { kingpin.Version(Version) kingpin.Parse() setupLoggo(*debug) //localRegistry := metrics.NewRegistry() //publisher := newPublisher(localRegistry) //publisher := newLitePublisher() mqttEngine, mqerr := newMqttEngine(*mqttURL) wbEngine, wberr := NewWebBrickDriver(mqttEngine) if mqerr != nil && wberr != nil { panic(err) } wbEngine.Start() //ws := newWsServer(localRegistry) //go ws.listenAndServ(*port, *path) // Set up channel on which to send signal notifications. sigc := make(chan os.Signal, 1) signal.Notify(sigc, os.Interrupt, os.Kill) // Wait for receiving a signal. <-sigc // Disconnect the Network Connection. if err := engine.disconnect(); err != nil { panic(err) } }
func init() { m = macaron.Classic() m.Use(modules.Public) if _, err := os.Stat("templates"); err == nil { m.Use(macaron.Renderer()) } else { m.Use(modules.Renderer) } kingpin.HelpFlag.Short('h') kingpin.Version(VERSION) kingpin.Flag("port", "Port to listen").Default("8000").IntVar(&gcfg.port) kingpin.Flag("root", "File root directory").Default(".").StringVar(&gcfg.root) kingpin.Flag("private", "Only listen on loopback address").BoolVar(&gcfg.private) kingpin.Flag("httpauth", "HTTP basic auth (ex: user:pass)").Default("").StringVar(&gcfg.httpauth) kingpin.Flag("cert", "TLS cert.pem").StringVar(&gcfg.cert) kingpin.Flag("key", "TLS key.pem").StringVar(&gcfg.key) kingpin.Flag("gzip", "Enable Gzip support").BoolVar(&gcfg.gzip) //kingpin.Flag("ftp", "Enable FTP support").BoolVar(&gcfg.ftp) //kingpin.Flag("ftp-port", "FTP listen port").Default("2121").IntVar(&gcfg.ftpPort) //kingpin.Flag("ftp-auth", "FTP auth (ex: user:pass)").Default("admin:123456").StringVar(&gcfg.ftpAuth) kingpin.Flag("upload", "Enable upload support").BoolVar(&gcfg.upload) kingpin.Flag("zipable", "Enable archieve folder into zip").BoolVar(&gcfg.zipable) }
func main() { kingpin.Version(fmt.Sprintf("%s %s", kingpin.CommandLine.Name, version)) kingpin.Parse() level, err := oplogging.LogLevel(*loglevel) if err != nil { prefixedUserError("Bad loglevel: %s", loglevel) os.Exit(1) } logging.SetLevel(level) diffCmd, err := shellwords.NewParser().Parse(*diffCommand) if err != nil { userError("Error parsing diff command %q: %s", *diffCommand, err.Error()) os.Exit(1) } tests, err := testcase.DiscoverTests(*testcasePath) if err != nil { userError(err.Error()) os.Exit(1) } if err = runTests(*logstashPath, tests, *configPaths, diffCmd, *keptEnvVars); err != nil { userError(err.Error()) os.Exit(1) } os.Exit(0) }
func main() { kingpin.Version("0.2.1") kingpin.Parse() switch *format { case "html": openBrowser() case "json": fetchJSON() default: openBrowser() } }
func main() { kingpin.Version("0.1") kingpin.Parse() f, err := os.OpenFile(*logfile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666) if err != nil { panic(err) } defer f.Close() LogInit(f) GetClusterReport(*conf) }
func main() { kingpin.Version("0.1") kingpin.Parse() ttyPath := *device fmt.Println("Writing packets to: " + ttyPath) fmt.Println("Packets are formatted all lower case hex, [src] [dest] [message...]") fmt.Println("Quote ascii strings for text conversion") serialConfig := &serial.Config{Name: ttyPath, Baud: 9600, Parity: serial.PARITY_EVEN} port, err := serial.OpenPort(serialConfig) if err != nil { panic(err) } go func() { parser := ibus.NewIbusPacketParser() for { buffer := make([]byte, 1) _, err := port.Read(buffer) if err != nil { panic(err) } parser.Push(buffer) if parser.HasPacket() { pkt := parser.GetPacket() // echo received packets to simulate bus broadcast port.Write(pkt.AsBytes()) fmt.Println("\n<== " + pkt.AsString()) fmt.Print("Enter IBUS packet: ") } } }() for { reader := bufio.NewReader(os.Stdin) fmt.Print("Enter IBUS packet: ") text, _ := reader.ReadString('\n') text = strings.TrimSpace(text) hexChars := strings.Split(text, " ") packet := new(ibus.IbusPacket) packet.Src = hexChars[0] packet.Dest = hexChars[1] packet.Message = hexChars[2:len(hexChars)] fmt.Println("==> " + packet.AsString()) bytes := packet.AsBytes() port.Write(bytes) } }
func main() { kingpin.Version("0.1") kingpin.Parse() f, err := os.OpenFile(*logfile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666) if err != nil { panic(err) } defer f.Close() LogInit(*verbose, f) osd_sockets, err := filepath.Glob(*osd_sockets) if err != nil { log.Error("No sockets found exiting") } log.Info("Found following sockets", osd_sockets) c := make(chan perf) perfcounters := make([]PerfCounter, len(osd_sockets)) for _, osd_socket := range osd_sockets { go func() { result, err := QueryAdminSocket(osd_socket) if err != nil { log.Fatal("Querying Socket failed with ", err) } c <- perf{*result, err} }() query := <-c if query.error == nil { perfcounters = append(perfcounters, query.PerfCounter) // perf_json, err := json.Marshal(query.PerfCounter) // if err == nil { // fmt.Println(string(perf_json)) // } token, err := get_token() if err == nil { PostPerfCeilometer(token, query.PerfCounter) } } } GetClusterStatus(*conf) GetClusterIOPs(*conf) }
func parseFlags() { kingpin.HelpFlag.Short('h') kingpin.Version(versionMessage()) kingpin.Flag("root", "root directory").Short('r').Default("./").StringVar(&gcfg.Root) kingpin.Flag("addr", "listen address").Short('a').Default(":8000").StringVar(&gcfg.Addr) kingpin.Flag("cert", "tls cert.pem path").StringVar(&gcfg.Cert) kingpin.Flag("key", "tls key.pem path").StringVar(&gcfg.Key) kingpin.Flag("httpauth", "HTTP basic auth (ex: user:pass)").Default("").StringVar(&gcfg.HttpAuth) kingpin.Flag("theme", "web theme, one of <black|green>").Default("black").StringVar(&gcfg.Theme) kingpin.Flag("upload", "enable upload support").BoolVar(&gcfg.Upload) kingpin.Flag("xheaders", "used when behide nginx").BoolVar(&gcfg.XHeaders) kingpin.Flag("cors", "enable cross-site HTTP request").BoolVar(&gcfg.Cors) kingpin.Flag("plistproxy", "plist proxy when server is not https").Default(defaultPlistProxy).Short('p').URLVar(&gcfg.PlistProxy) kingpin.Flag("title", "server title").Default("Go HTTP File Server").StringVar(&gcfg.Title) kingpin.Parse() }
func main() { kingpin.Version("1.3") kingpin.Parse() api := slack.New(*token) for { users, _ := api.UsersList() svc := ec2.New(session.New(), &aws.Config{Region: aws.String(*region)}) // Call the DescribeInstances Operation resp, err := svc.DescribeInstances(nil) if err != nil { panic(err) } usersInstances := findLongRunningInstances(resp, users) alreadyNotified := getAlreadyNotified() for user, instances := range usersInstances { msg := "" for _, inst := range instances { if !contains(alreadyNotified, *inst.InstanceId) { msg += fmt.Sprintf("`%v - %v` with id _%v_\n", getTagValue(inst.Tags, "Purpose"), getTagValue(inst.Tags, "Name"), *inst.InstanceId) alreadyNotified = append(alreadyNotified, *inst.InstanceId) } } if msg != "" { msg := "\nYou have the following instances running in amazon:\n\n" + msg msg += "They were all started more then two days ago, are they still needed ?" if user == "U02HSGZ3F" || *prod { // ME err = api.ChatPostMessage(user, msg, &slack.ChatPostMessageOpt{Username: "******"}) } } } saveAlreadyNotified(alreadyNotified) time.Sleep(time.Duration(*timeout) * time.Minute) } }
func main() { kingpin.Version("0.0.1") kingpin.Parse() fmt.Printf("Would ping: %s with timeout %s and count %d", *ip, *timeout, *count) }