Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var HubCmd = &cobra.Command{ Use: "hub", Short: "Graffiti hub", Long: "Graffiti hub", SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { logging.GetLogger().Noticef("Graffiti hub starting...") hostname, err := os.Hostname() if err != nil { logging.GetLogger().Errorf("Failed to get hostname: %s", err) os.Exit(1) } authBackend := shttp.NewNoAuthenticationBackend() if len(etcdServers) == 0 { logging.GetLogger().Error("No Etcd server provided") os.Exit(1) } etcdClientOpts := etcdclient.Opts{ Servers: etcdServers, Timeout: 5 * time.Second, } etcdClient, err := etcdclient.NewClient(hostname, etcdClientOpts) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } origin := "graffiti-hub" cached, err := graph.NewCachedBackend(nil, etcdClient, hostname, service.Type(origin)) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } g := graph.NewGraph(hostname, cached, origin) hubOpts := hub.Opts{ Hostname: hostname, WebsocketOpts: websocket.ServerOpts{ WriteCompression: writeCompression, QueueSize: queueSize, PingDelay: time.Second * time.Duration(pingDelay), PongTimeout: time.Second * time.Duration(pongTimeout), }, APIAuthBackend: authBackend, ClusterAuthBackend: authBackend, EtcdClient: etcdClient, } var etcdServer *etcdserver.EmbeddedServer if embeddedEtcd { hubOpts.EtcdServerOpts = &etcdserver.EmbeddedServerOpts{ Name: "localhost", Listen: "127.0.0.1:12379", DataDir: "/tmp/etcd", } } hub, err := hub.NewHub(hostname, service.Type("Hub"), hubListen, g, cached, "/ws/pod", hubOpts) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } api.RegisterStatusAPI(hub.HTTPServer(), hub, authBackend) hub.Start() logging.GetLogger().Notice("Graffiti hub started !") ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) <-ch hub.Stop() if etcdServer != nil { etcdServer.Stop() } logging.GetLogger().Notice("Graffiti hub stopped.") }, }
HubCmd describes the graffiti hub command
View Source
var PodCmd = &cobra.Command{ Use: "pod", Short: "Graffiti pod", Long: "Graffiti pod", SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { logging.GetLogger().Noticef("Graffiti pod starting...") hostname, err := os.Hostname() if err != nil { logging.GetLogger().Errorf("Failed to get hostname: %s", err) os.Exit(1) } backend, err := graph.NewMemoryBackend() if err != nil { logging.GetLogger().Errorf("Failed to get hostname: %s", err) os.Exit(1) } clusterAuthOptions := &shttp.AuthenticationOpts{} g := graph.NewGraph(hostname, backend, "graffiti-pod") authBackend := shttp.NewNoAuthenticationBackend() var addresses []service.Address for _, address := range hubServers { sa, err := service.AddressFromString(address) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } addresses = append(addresses, sa) } if len(addresses) == 0 { logging.GetLogger().Info("Pod is running in standalone mode") } clientOpts := websocket.ClientOpts{ AuthOpts: clusterAuthOptions, WriteCompression: writeCompression, QueueSize: queueSize, } clientPool := newHubClientPool(hostname, addresses, clientOpts) podOpts := pod.Opts{ WebsocketOpts: websocket.ServerOpts{ WriteCompression: writeCompression, QueueSize: queueSize, PingDelay: time.Second * time.Duration(pingDelay), PongTimeout: time.Second * time.Duration(pongTimeout), }, APIAuthBackend: authBackend, } pod, err := pod.NewPod(hostname, serviceType, podListen, "/ws/pod", g, podOpts) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } go clientPool.ConnectAll() pod.Start() logging.GetLogger().Notice("Graffiti pod started !") ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) <-ch logging.GetLogger().Notice("Graffiti pod stopped.") }, }
PodCmd describes the graffiti pod command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.