Exemplo n.º 1
0
func TestSchedulerIsRunning(t *testing.T) {
	scheduler.Run()
	if !scheduler.IsRunning() {
		t.Fail()
		t.Log("Scheduler is not running")
	}
}
Exemplo n.º 2
0
func launchServer(flag *flag.Flag) error {
	path, err := config.GetString("assets")
	if err != nil {
		return errors.New("No assets folder specified in config file.")
	}

	scheduler.Run()

	http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir(path))))

	r := pat.New()

	r.Post("/schedules/{scheduleId}", updateSchedule)
	r.Get("/schedules/{scheduleId}/edit", editSchedule)
	r.Get("/schedules/new", newSchedule)
	r.Post("/schedules", createSchedule)

	r.Get("/valves/{valveId}/edit", editValve)
	r.Get("/valves/{valveId}/open", openValve)
	r.Get("/valves/{valveId}/close", closeValve)
	r.Post("/valves/{valveId}", updateValve)
	r.Get("/valves/{valveId}", showValve)

	r.Get("/manual", manual)
	r.Get("/", homepage)

	http.Handle("/", r)

	initializeTemplates(path)

	err = http.ListenAndServe(":7777", nil)

	return err

}