Beispiel #1
0
func main() {
	sift.SetLogLevel("debug")
	//ipv4.Log.SetHandler(log.DiscardHandler()) // ignore ipv4 scanner stuff

	// Instantiate a SIFT server
	server, err := sift.NewServer(sift.DefaultDBFilepath)
	if err != nil {
		panic(err)
	}
	if err = server.AddDefaults(); err != nil {
		panic(err)
	}

	// Start the server as a suture process
	supervisor := suture.NewSimple("repeat to console (SIFT app)")
	servToken := supervisor.Add(server)
	defer supervisor.Remove(servToken)
	go supervisor.ServeBackground()

	// Run the SIFT script
	repeatUpdatesToConsole(server)
}
Beispiel #2
0
func main() {
	sift.SetLogLevel("info")
	server := example.NewServer(example.defaultPort)
	go server.Serve()
	//	supervisor := suture.NewSimple("SIFT example main")
	//	supervisor.Add(server)
	//	go supervisor.ServeBackground()
	// go server.serveHTTP()

	// Insert a device
	light1 := example.light{
		baseComponent:   example.baseComponent{Type: example.componentTypeLight},
		IsOn:            true,
		OutputInPercent: 100,
	}
	device1 := example.device{
		Components: map[string]example.component{"light 1": light1},
	}
	server.SetDevice("device 1", device1)

	fmt.Printf("SIFT example server started\n")
	select {} // wait forever
}
Beispiel #3
0
func (s *MySuite) TestNotifier(c *C) {
	sift.SetLogLevel("error")
	n := notif.New(auth.New())
	c.Check(n, NotNil)
}