Пример #1
0
func Listen() {
	logger := iDnegroniLog.NewMiddleware(idl.StandardLogger())

	logger.Stack2Http = config.AnaLog.DevelopmentEnv

	n := negroni.New(logger /*negroni.NewStatic(http.Dir(helper.GetFilePath("./public")))*/)

	cookiestore := cookiestore.New([]byte(config.AnaLog.CookieSecret))
	n.Use(sessions.Sessions("perm_analog_session", cookiestore))
	n.Use(negroni.HandlerFunc(preflight))

	n.UseHandler(router.New())

	if config.AnaLog.UseSocketMaster {
		listener, err := client.Listen(protocol.SocketDefinition{
			Port: config.SocketMaster.Port,
			HTTP: &protocol.SocketHTTPDefinition{
				DomainSuffix: config.SocketMaster.DomainSuffix,
				PathPrefix:   config.SocketMaster.PathPrefix,
			},
			/*TLS: &protocol.SocketTLSDefinition{
				Cert: config.SocketMaster.Cert,
				Key:  config.SocketMaster.Key,
			},*/
		})
		if err != nil {
			idl.Emerg(err)
		}
		idl.Notice("Serving via SocketMaster")
		http.Serve(listener, n)
	} else if config.AnaLog.Fcgi {
		listener, err := net.Listen("tcp", config.AnaLog.Listen)
		if err != nil {
			idl.Emerg(err)
		}
		idl.Notice("Serving via FastCGI")
		fcgi.Serve(listener, n)
	} else {
		idl.Notice("Serving via inbuilt HTTP Server")
		n.Run(config.AnaLog.Listen)
	}
}
Пример #2
0
func RecurringTaskIncoming(begin logpoint.LogPoint) {
	dur, err := analysis.RecurringExpectedAfter(begin)
	if err == analysis.NoRecurringData {
		idl.Notice(`Skipping analysis scheduling of recurring task "` + begin.Task + `" due to missing data`)
		return
	}
	if err != nil {
		idl.Crit("Failed scheduling for analysis of recurring task", err, begin)
	}

	<-time.After(dur)
	err = analysis.CheckRecurredTaskEnd(begin)
	if err != nil {
		idl.Crit("Failed analysis of recurring task", err, begin)
	}
}
Пример #3
0
func Start() {
	if config.AnaLog.SchedulerInterval == "" {
		idl.Notice("Scheduling disabled")
		return
	}
	dur, err := time.ParseDuration(config.AnaLog.SchedulerInterval)
	if err != nil {
		idl.Emerg("Invalid configuration: AnaLog.SchedulerInterval")
	}

	go func() {
		pingAll(time.Now())
	}()

	c := time.Tick(dur)
	go loop(c)
	go RecurringBeginWatcher()
}