Ejemplo n.º 1
0
func Action(c *cli.Context) {
	var err error
	if err = config.Load(c.String("conf")); err != nil {
		log.Fatal(err)
	}
	if err = models.InitDB(); err != nil {
		log.Fatal(err)
	}
	cfg := config.Config

	xrpc.HandleRpc()
	m := newMartini()
	routers.Register(m)

	http.Handle("/", m)

	if err = models.ResetAllTaskStatus(); err != nil {
		log.Fatalf("reset all task status: %v", err)
	}
	go drainTask()

	listenAddr := fmt.Sprintf("%s:%d",
		cfg.Server.Addr,
		cfg.Server.Port)
	log.Printf("listen %s\n", strconv.Quote(listenAddr))
	log.Fatal(http.ListenAndServe(listenAddr, nil))
}
Ejemplo n.º 2
0
func main() {
	addr := flag.String("http", ":8877", "HTTP service address")
	hookby := flag.String("hookby", "gogs", "hook by which service")
	flag.Parse()

	log.Printf("Hook for %s, Listening on %s\n", *hookby, *addr)
	log.Fatal(http.ListenAndServe(*addr, nil))
}
Ejemplo n.º 3
0
func colorPrintf(ansiColor string, format string, args ...interface{}) {
	if runtime.GOOS != "windows" {
		format = "\033[" + ansiColor + "m" + format + "\033[0m"
	}
	log.Printf(format, args...)
}