Exemple #1
0
func init() {
	server := web.NewServer(":3000", []web.Handler{
		new(web.SlashHandler),
		new(web.CorsHandler),
	}, Routes)
	server.AuthHandler = &web.AuthHandler{Auth: AuthHandler}
	server.Prestart()
	broomeServer = server.Handler.ServeHTTP
}
Exemple #2
0
func main() {
	var err error
	ver := false
	runtime.GOMAXPROCS(1)
	pusherC = pusher.NewClient(config.PusherAppID, config.PusherKey, config.PusherSecret)
	flag.StringVar(&dockerAddr, "docker", "unix:///var/run/docker.sock", "Set a custom endpoint for your local Docker service")
	flag.StringVar(&Env, "env", "production", "If you want to run the agent in development mode uses different ports")
	flag.BoolVar(&ver, "version", false, "Print the version")
	flag.Parse()
	if ver {
		fmt.Println(VERSION)
		os.Exit(0)
	}

	fmt.Println("Starting up Delancey with Docker at", dockerAddr)
	DockerClient, err = docker.NewClient(dockerAddr)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	err = DockerClient.PullImage(config.DockerBaseImage+":latest", nil)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	currentContainer, _ = LoadContainer()

	go logClient.Info("agent starting", map[string]interface{}{
		"version": VERSION,
		"arch":    runtime.GOARCH,
		"os":      runtime.GOOS,
		"ip":      agentHost,
	})

	port := config.DelanceyProdPort
	if Env == "development" {
		port = config.DelanceyDevPort
	}

	server := web.NewServer(":"+port, []web.Handler{
		new(web.SlashHandler),
	}, Routes)
	server.AuthHandler = &web.AuthHandler{Auth: web.DefaultAuthHandler}

	err = server.ListenAndServe()
	if err != nil {
		go logClient.Error(err.Error(), map[string]interface{}{
			"ip": agentHost,
		})
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}
Exemple #3
0
func main() {
	ver := false
	flag.StringVar(&env, "env", "development", "Mode to run client in.")
	flag.StringVar(&port, "port", ":32055", "Port to listen on.")
	flag.BoolVar(&ver, "version", false, "Print the version")
	flag.Parse()
	if ver {
		fmt.Println(VERSION)
		return
	}

	ssePool = sse.NewPool()
	go ssePool.Run()

	rollbarC = rollbar.NewClient(config.RollbarToken, env)
	containerManager = NewContainerManager()
	defer containerManager.Close()

	go func() {
		for {
			select {
			case ev := <-containerManager.Syncer.Event:
				if len(ev.Paths) == 1 {
					log.Println("Sync event", ev.Status, "change", ev.Paths[0])
				} else {
					log.Println("Sync event", ev.Status, "changes", len(ev.Paths))
				}

				msg := map[string]interface{}{
					"event": ev,
					"type":  "sync",
				}
				ssePool.Messages <- msg
			case err := <-containerManager.Syncer.Error:
				log.Println(err)
			}
		}
	}()

	abs, _ := filepath.Abs(filepath.Join(filepath.Dir(os.Args[0]), "../ui/"))
	AbsPath = abs

	server := web.NewServer(port, []web.Handler{
		new(web.SlashHandler),
		new(web.CorsHandler),
	}, routes)
	server.AuthHandler = &web.AuthHandler{Auth: web.DefaultAuthHandler}

	server.ListenAndServe()
}
Exemple #4
0
func main() {
	slackC = slack.NewClient(config.SlackToken)

	port := ":4000"
	if os.Getenv("ENV") == "production" {
		port = ":80"
	}

	server := web.NewServer(port, []web.Handler{
		new(web.SlashHandler),
		new(web.CorsHandler),
		&web.StatHandler{Key: config.StatHatKey, Name: "broome"},
	}, Routes)
	server.AuthHandler = &web.AuthHandler{Auth: AuthHandler}
	server.ListenAndServe()
}