Exemplo n.º 1
0
func AnalyzeRecurring(w http.ResponseWriter, req *http.Request) *webapp.Error {
	_, err := hostnamesec.GetValidHost(req.RemoteAddr)
	if err != nil {
		idl.Emerg(err)
	}
	ta, err := anaLog.AnalyzeRecurring()
	fmt.Fprintln(w, ta, err)
	return nil
}
Exemplo n.º 2
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)
	}
}
Exemplo n.º 3
0
func connect2influx() *influx.Client {
	db = config.Influx.Database

	u, err := url.Parse(fmt.Sprintf("http://%s:%d", config.Influx.Host, config.Influx.Port))
	if err != nil {
		idl.Emerg(err)
	}

	conf := influx.Config{
		URL:      *u,
		Username: config.Influx.User,
		Password: config.Influx.Pass,
	}

	con, err := influx.NewClient(conf)
	if err != nil {
		idl.Emerg(err)
	}

	return con
}
Exemplo n.º 4
0
func init() {
	ConfigPath := flag.String("conf", "./config.gcfg", "Specify a file containing the configuration or \"./config.gcfg\" is used")
	flag.Parse()
	cfg := &Config{}
	err := gcfg.ReadFileInto(cfg, *ConfigPath)

	if err != nil {
		iDlogger.Emerg("config: ", err)
	}

	if cfg.AnaLogCfg.UseSocketMaster && cfg.AnaLogCfg.Fcgi {
		iDlogger.Emerg("Invalid configuration: Can't serve via FastCGI AND SocketMaster simultaneously. Disable one of them!")
	}

	if cfg.AnaLogCfg.UseSocketMaster && cfg.AnaLogCfg.Listen != "" {
		iDlogger.Emerg("Invalid configuration: Can't serve via inbuilt HTTP Server AND SocketMaster simultaneously. Disable one of them!")
	}

	if !(cfg.AnaLogCfg.UseInflux || cfg.AnaLogCfg.UseMongo) || (cfg.AnaLogCfg.UseInflux && cfg.AnaLogCfg.UseMongo) {
		iDlogger.Emerg("Invalid configuration: Exactly one database backend has to be defined")
	}

	fillVars(cfg)
}
Exemplo n.º 5
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()
}