Example #1
0
func init() {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println(r)
			os.Exit(0)
		}
	}()
	val, err := config.Load()
	if err != nil {
		panic(fmt.Errorf("API: %s", err))
	}
	port = val.Port
}
Example #2
0
func init() {
	flag.BoolVar(&runAPI, "api", false, "Turn on API mode")
	flag.Parse()

	defer func() {
		if r := recover(); r != nil {
			fmt.Println(r)
			os.Exit(0)
		}
	}()

	cfg, err := config.Load()
	if err != nil {
		panic(fmt.Errorf("main.init: Could not load the config.\n %v", err))
	}

	logList = cfg.LogList
	outputFile = cfg.OutputFile
}
Example #3
0
// initialize email service used for notifications
// 1. MailGun
// 2. SMTP package
// 3. Send to JSON
func init() {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println(r)
			os.Exit(0)
		}
	}()

	if ByPassMail {
		emailOption = jsonSend
		return
	}
	val, err := config.Load()
	if err != nil {
		panic(fmt.Errorf("email.init: Failed to load Main config file"))
	}

	// Get values from the main config.
	EmailList = val.EmailList
	OutputFile = val.OutputFile

	mGun, err = config.LoadSecret()
	if err != nil {
		// Check smtp server
		smtpConfig, err = config.LoadSMTP()
		if err != nil {
			// Use JSON
			emailOption = jsonSend
			return
		}
		// Use SMTP
		emailOption = smtpSend
		return
	}
	// Use MailGun
	emailOption = mailGunSend
}