Пример #1
0
func doMain() error {
	if err := logging.EnableFileLogging(); err != nil {
		return err
	}

	// Schedule cleanup actions
	handleSignals()
	addExitFunc(func() {
		if err := logging.Close(); err != nil {
			log.Debugf("Error closing log: %v", err)
		}
	})
	addExitFunc(quitSystray)

	i18nInit()
	if showui {
		if err := configureSystemTray(); err != nil {
			return err
		}
	}

	// Run below in separate goroutine as config.Init() can potentially block when Lantern runs
	// for the first time. User can still quit Lantern through systray menu when it happens.
	go func() {
		if *proxyAll {
			// If proxyall flag was supplied, force proxying of all
			settings.SetProxyAll(true)
		}

		listenAddr := *addr
		if listenAddr == "" {
			listenAddr = "localhost:8787"
		}
		err := flashlight.Run(
			listenAddr,
			"localhost:8788",
			*configdir,
			*stickyConfig,
			settings.GetProxyAll,
			flagsAsMap(),
			beforeStart,
			afterStart,
			onConfigUpdate,
			exit)
		if err != nil {
			exit(err)
			return
		}
	}()

	return waitForExit()
}
Пример #2
0
func logPanic(msg string) {
	cfg, err := config.Init(flashlight.PackageVersion, *configdir, *stickyConfig, flagsAsMap())
	if err != nil {
		panic("Error initializing config")
	}
	if err := logging.EnableFileLogging(); err != nil {
		panic("Error initializing logging")
	}

	<-logging.Configure(eventual.DefaultGetter(""), "", cfg.Client.DeviceID, flashlight.Version, flashlight.RevisionDate)

	log.Error(msg)

	logging.Flush()
	_ = logging.Close()
}