Exemplo n.º 1
0
func main() {
	conf.Use(configure.NewEnvironment())
	conf.Use(configure.NewFlag())

	conf.Parse()

	restrict.ReadCryptoKey(*crypto)

	models.Init(
		*dbUser,
		*dbPass,
		*dbService,
		*dbPort,
		*dbName,
	)

	fmt.Println("Welcome to pay.")

	r := mux.NewRouter().PathPrefix("/api").Subrouter().StrictSlash(true)

	r.HandleFunc("/ping", restrict.R(pingHandler)).
		Methods("GET")

	r.HandleFunc("/users", registerHandler).
		Methods("POST")
	r.HandleFunc("/users", loginHandler).
		Methods("GET")

	fmt.Println(http.ListenAndServe(":8080", r))
}
Exemplo n.º 2
0
func init() {
	conf.Use(configure.NewEnvironment())
	conf.Use(configure.NewFlag())

	conf.Parse()

	messages = make(chan tunnel.MessageArgs)
	clients = make(map[string][]*conn)
}
Exemplo n.º 3
0
Arquivo: bot.go Projeto: BigRoom/profx
func main() {
	var err error

	conf.Use(configure.NewFlag())
	conf.Use(configure.NewEnvironment())
	conf.Parse()

	models.Init(
		*dbUser,
		*dbPass,
		*dbService,
		*dbPort,
		*dbName,
	)

	_, err = logrus_sentry.NewSentryHook(*sentryDSN, []log.Level{
		log.PanicLevel,
		log.FatalLevel,
		log.ErrorLevel,
	})

	if err != nil {
		log.WithFields(log.Fields{
			"error": err,
		}).Fatal("Unable to get connect to sentry")

		return
	}

	bot := ircx.Classic(*serverName, *name)

	log.WithFields(log.Fields{
		"address": *serverName,
	}).Info("Starting connection to the IRC server")

	reconnect(bot.Connect, "IRC")

	bot.HandleFunc(irc.RPL_WELCOME, registerHandler)
	bot.HandleFunc(irc.PING, pingHandler)
	bot.HandleFunc(irc.PRIVMSG, msgHandler)
	bot.HandleFunc(irc.INVITE, inviteHandler)

	log.WithFields(log.Fields{
		"address": *dispatch,
	}).Info("Starting connection to RPC the server")

	reconnect(connectRPC, "RPC")

	bot.HandleLoop()

	log.Println("finished")
}
Exemplo n.º 4
0
func LoadEnvConfiguration(filename string) *EnvConfiguration {

	conf := configure.New()
	glog.V(0).Infof("Loading configuration from 1. shell variables")
	conf.Use(configure.NewEnvironment())
	if filename != "" {
		glog.V(0).Infof("Loading configuration from 2. json file: %s", filename)
		if file, err := os.Open(filename); err != nil {
			// TODO What if we wanted to pass all configuration via env variables, not possible as of today
			glog.Fatalf("Could not open Environment configuration file: %s", filename)
		} else {
			file.Close()
			conf.Use(configure.NewJSONFromFile(filename))
		}
	}

	// environment specifics
	checkerPhoneNumber := conf.String("GOLAM_CHECKER_NUMBER", "", "the checker phone number to automate new messages check")
	checkerName := conf.String("GOLAM_CHECKER_NAME", "", "to enhance the welcome message of the new messages checker")
	recorderEndpoint := conf.String("GOLAM_RECORDER_ENDPOINT", "", "to receive the recordings")
	recorderUsername := conf.String("GOLAM_RECORDER_USERNAME", "", "credentials to the recorder endpoint")
	recorderPassword := conf.String("GOLAM_RECORDER_PASSWORD", "", "credentials to the recorder endpoint")
	audioEndpoint := conf.String("GOLAM_AUDIO_ENDPOINT", "", "audio files server")
	transcriptsEmail := conf.String("GOLAM_TRANSCRIPTS_EMAIL", "", "to receive transcripts via email")
	dbFilename := conf.String("GOLAM_DATABASE_PATH", "messages.db", "path to the messages database")
	dbResetAtStartup := conf.Bool("GOLAM_DATABASE_RESET", true, "flag to empty messages at startup")

	conf.Parse()

	var env EnvConfiguration
	env.RecorderEndpoint = *recorderEndpoint
	env.RecorderUsername = *recorderUsername
	env.RecorderPassword = *recorderPassword
	env.AudioServerEndpoint = *audioEndpoint
	env.TranscriptsReceiver = "mailto:" + *transcriptsEmail
	env.CheckerPhoneNumber = *checkerPhoneNumber
	env.CheckerFirstName = *checkerName
	env.DBfilename = *dbFilename
	env.DBresetAtStartup = *dbResetAtStartup

	return &env
}
Exemplo n.º 5
0
func main() {
	var err error

	conf.Use(configure.NewEnvironment())
	conf.Use(configure.NewFlag())

	conf.Parse()

	sentry, err = raven.NewClient(*sentryDSN, nil)
	if err != nil {
		log.WithFields(log.Fields{
			"dsn":   *sentryDSN,
			"error": err,
		}).Warn("Could not connect to sentry")
	}

	rand.Seed(time.Now().UnixNano())
	uid = rand.Int63()

	setupETCD()

	pool = zombies.New()

	k := kite.New("pool", "1.0.0")

	k.Config.Port = *port
	k.Config.IP = "0.0.0.0"

	bindHandlers(k)

	go k.Run()

	<-k.ServerReadyNotify()

	log.WithFields(log.Fields{
		"port": k.Port,
		"ip":   k.Config.IP,
	}).Info("Pool is ready")

	<-k.ServerCloseNotify()
}
// Load default messages from file
// The file is in json format and contains one or more of the entries:
// - GOLAM_VOICE
// - GOLAM_WELCOME
// - GOLAM_WELCOME_ALT
// - GOLAM_CHECK_NO_MESSAGE
// - GOLAM_CHECK_NEW_MESSAGES
// - GOLAM_RECORDING_OK
// - GOLAM_RECORDING_FAILED
// If an entry is not present, a default english message is added
func LoadMessagesConfiguration(filename string) *I18nMessages {

	conf := configure.New()
	glog.V(0).Infof("Loading env preferences from 1. env variables")
	conf.Use(configure.NewEnvironment())
	if filename != "" {
		glog.V(0).Infof("Loading messages from: %s", filename)
		if file, err := os.Open(filename); err != nil {
			glog.Warningf("Could not open Messages definition, switching to default values", filename)
		} else {
			file.Close()
			conf.Use(configure.NewJSONFromFile(filename))
		}
	}

	// messages
	defaultVoice := conf.String("GOLAM_VOICE", "Vanessa", "defaults to English")
	welcome := conf.String("GOLAM_WELCOME", "Welcome, please leave a message after the beep", "to enhance the welcome message of the new messages checker")
	welcomeAlt := conf.String("GOLAM_WELCOME_ALT", "Sorry we do not take any message currently, please call again later", "alternative message if storage service could not be started")
	checkNoMessage := conf.String("GOLAM_CHECK_NO_MESSAGE", "Hello %s, no new messages. Have a good day !", "")
	checkNewMessage := conf.String("GOLAM_CHECK_NEW_MESSAGES", "Hello %s, you have %d new messages", "")
	recordingOK := conf.String("GOLAM_RECORDING_OK", "Your message is recorded. Have a great day !", "")
	recordingFailed := conf.String("GOLAM_RECORDING_FAILED", "Sorry, we could not record your message. Please try again later", "")

	conf.Parse()

	var messages I18nMessages
	messages.DefaultVoice = tropo.GetVoice(*defaultVoice)
	messages.WelcomeMessage = *welcome
	messages.WelcomeAltMessage = *welcomeAlt
	messages.CheckNewMessages = *checkNewMessage
	messages.CheckNoMessage = *checkNoMessage
	messages.RecordingOKMessage = *recordingOK
	messages.RecordingFailedMessage = *recordingFailed

	return &messages
}
Exemplo n.º 7
0
func init() {
	config.Use(configure.NewEnvironment())
	config.Use(configure.NewFlagWithUsage(usage))
}