Esempio n. 1
0
func main() {
	filename := flag.String("conf", "/etc/skydive/skydive.ini",
		"Config file with all the skydive parameter.")
	flag.CommandLine.Usage = usage
	flag.Parse()

	err := config.InitConfigFromFile(*filename)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%v\n", err)
		os.Exit(1)
	}

	logging.GetLogger().Notice("Skydive Agent starting...")
	agent := agent.NewAgent()
	agent.Start()

	ch := make(chan os.Signal)
	signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
	<-ch

	agent.Stop()

	logging.GetLogger().Notice("Skydive Agent stopped.")
}
Esempio n. 2
0
var Agent = &cobra.Command{
	Use:          "agent",
	Short:        "Skydive agent",
	Long:         "Skydive agent",
	SilenceUsage: true,
	Run: func(cmd *cobra.Command, args []string) {
		logging.GetLogger().Notice("Skydive Agent starting...")
		agent := agent.NewAgent()
		agent.Start()

		ch := make(chan os.Signal)
		signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
		<-ch

		agent.Stop()

		logging.GetLogger().Notice("Skydive Agent stopped.")
	},
}

func init() {
	Agent.Flags().String("listen", "127.0.0.1:8081", "address and port for the agent API")
	config.GetConfig().BindPFlag("agent.listen", Agent.Flags().Lookup("listen"))

	Agent.Flags().String("ovsdb", "127.0.0.1:6400", "ovsdb connection")
	config.GetConfig().BindPFlag("ovs.ovsdb", Agent.Flags().Lookup("ovsdb"))

	Agent.Flags().String("graph-backend", "memory", "graph backend")
	config.GetConfig().BindPFlag("graph.backend", Agent.Flags().Lookup("graph-backend"))