Esempio n. 1
0
func Start() {
	fmt.Println("Starting Liliput..")
	syslog.Openlog("lilliput", syslog.LOG_PID, syslog.LOG_USER)

	m := martini.Classic()
	// render home page
	m.Use(render.Renderer(render.Options{
		Directory:  "static",
		Extensions: []string{".html"},
		Charset:    "UTF-8",
	}))

	gorelic.InitNewrelicAgent(Get("newrelic.license", "").(string), Get("lilliput.domain", "").(string), true)
	m.Use(gorelic.Handler)

	m.Get("/:token", Redirect)
	m.Get("/", func(r render.Render) {
		r.HTML(200, "index", nil)
	})
	m.Post("/", TinyUrl)
	server := fmt.Sprintf("%s:%s",
		Get("redis.server", ""),
		Get("redis.port", ""))
	m.Map(NewPool(server))

	port := fmt.Sprintf(":%v", Get("lilliput.port", ""))
	fmt.Println("Started on " + port + "...")
	http.Handle("/", m)
	http.ListenAndServe(port, nil)
	m.Run()
}
Esempio n. 2
0
func init() {
	if h, err := os.Hostname(); err == nil {
		config.Hostname = h
	} else {
		config.Hostname = "localhost"
	}

	if u, err := user.Current(); err == nil {
		config.Message_From = u.Username + "@" + config.Hostname

		if u.Name != "" {
			config.Message_FromName = u.Name
		} else {
			config.Message_FromName = u.Username
		}
	}

	if -1 == strings.Index(config.Postmaster, "@") {
		config.Postmaster += "@" + config.Hostname
	}

	syslog.Openlog("go-ssmtp", syslog.LOG_PID, syslog.LOG_USER)

	var ignore bool
	flag.BoolVar(&ignore, "i", false, "Ignore")
	flag.BoolVar(&ignore, "odi", false, "Ignore")
	flag.BoolVar(&config.Message_FromCronDaemon, "FCronDaemon", false, "Hack to allow crond to work with flag pkg")
	flag.BoolVar(&config.Message_FromCronDaemon, "FAnacron", false, "Hack to allow crond to work with flag pkg")
	flag.BoolVar(&config.Verbose, "v", config.Verbose, "Enable verbose mode")
	flag.StringVar(&config.ConfigFile, "C", config.ConfigFile, "Use alternate configuration file")
	flag.StringVar(&config.Message_From, "f", config.Message_From, "Manually specify the sender-address of the email")
	flag.StringVar(&config.Message_FromName, "F", config.Message_FromName, "Manually specify the sender-name of the email")
	flag.BoolVar(&config.ScanMessage, "t", config.ScanMessage, "Scan message for recipients")
}
Esempio n. 3
0
func init() {
	flag.Parse()

	switch {
	case *logType == "stderr":
		defer glog.Flush()
	case *logType == "syslog":
		syslog.Openlog(*logName, syslog.LOG_PID, syslog.LOG_USER)
		defer syslog.Closelog()
	default:
		fmt.Println("Incorrect flag passed! Run again with -h to see flag usage")
		os.Exit(1)
	}
}
Esempio n. 4
0
func InitLogging(logPath string) {

	syslog.Openlog("redis-happy", syslog.LOG_PID, syslog.LOG_USER)
	syslogWriter := &syslog.Writer{LogPriority: syslog.LOG_ERR}

	logFileWriter := newLogFileWriter(logPath)

	allOutputs := io.MultiWriter(logFileWriter, os.Stdout, syslogWriter)

	Trace = log.New(logFileWriter, "TRACE: ", log.Ldate|log.Ltime|log.Lshortfile)
	Info = log.New(logFileWriter, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
	Warning = log.New(allOutputs, "WARNING: ", log.Ldate|log.Ltime|log.Lshortfile)
	Error = log.New(allOutputs, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
	NoteWorthy = log.New(allOutputs, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
}
Esempio n. 5
0
func main() {
	syslog.Openlog("cvesync", syslog.LOG_PID, syslog.LOG_DAEMON)
	syslog.Info("Cvesync started")

	config = util.Load_Config("/opt/cvesync/etc/settings.json")
	blist = blacklist.Load_Blacklist(config.BlackList)
	cve_feed := nvd.Get_CVE_feed(config.FeedURL, config.CAKeyFile)
	cwes := nvd.Get_CWEs(config.CWEfile)

	ts := tracker.Jira{}
	//ts := tracker.RT{}
	sync(cve_feed, cwes, &ts)

	syslog.Info("Cvesync ended")
}
Esempio n. 6
0
func main() {

	syslog.Openlog("cinefade", syslog.LOG_PID, syslog.LOG_USER)

	var action string
	flag.StringVar(&action, "action", "on", "lights on/off")
	flag.Parse()

	bridge := cinefade.GetBridge(false)
	cinefade.MapRoutes(bridge)

	// make a http server using the goweb.DefaultHttpHandler()
	s := &http.Server{
		Addr:           Address,
		Handler:        goweb.DefaultHttpHandler(),
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	listener, listenErr := net.Listen("tcp", Address)
	syslog.Info("Server cinefade started")
	syslog.Infof("visit: %s", Address)

	if listenErr != nil {
		syslog.Critf("Could not listen: %s", listenErr)
		os.Exit(1)
	}

	go func() {
		for _ = range c {
			// sig is a ^C, handle it
			// stop the HTTP server
			syslog.Info("Stopping the cinefade server...")
			listener.Close()

			syslog.Info("Tearing down...")
			os.Exit(0)
		}
	}()

	syslog.Critf("Error in Serve: %s", s.Serve(listener))
	os.Exit(1)
}
Esempio n. 7
0
func init() {
	progname := os.Args[0]
	base := path.Base(progname)
	syslog.Openlog(base, syslog.LOG_PID, syslog.LOG_USER)
}