예제 #1
0
파일: main.go 프로젝트: way-2-go/gcollector
func init() {
	parseFlags()

	if options.concurrency != 0 {
		runtime.GOMAXPROCS(options.concurrency)
	}

	if options.showVersion {
		server.ShowVersionAndExit()
	}

	conf := server.LoadConfig(options.configFile)
	GcollectorConf = new(GcollectorConfig)
	GcollectorConf.LoadConfig(conf)

	if options.kill {
		if err := server.KillProcess(options.lockFile); err != nil {
			fmt.Fprintf(os.Stderr, "stop failed: %s\n", err)
			os.Exit(1)
		}
		etclib.Dial(GcollectorConf.EtcServers)
		loadLocalAddr()
		UnregisterEtc()

		os.Exit(0)
	}

	server.SetupLogging(options.logFile, options.logLevel, options.crashLogFile)

	if options.lockFile != "" {
		if locking.InstanceLocked(options.lockFile) {
			fmt.Fprintf(os.Stderr, "Another gcollector is running, exit...\n")
			os.Exit(1)
		}

		locking.LockInstance(options.lockFile)
	}

	signal.RegisterSignalHandler(syscall.SIGINT, func(sig os.Signal) {
		shutdown()
	})

	err := RegisterEtc(GcollectorConf.EtcServers)
	if err != nil {
		panic(err)
	}

	GcollectorConf.LoadForwarder(conf)

	rand.Seed(time.Now().UnixNano())
}
예제 #2
0
파일: main.go 프로젝트: cmotc/pushd
func init() {
	parseFlags()

	if options.showVersion {
		server.ShowVersionAndExit()
	}

	server.SetupLogging(options.logFile, options.logLevel, options.crashLogFile)

	conf := server.LoadConfig(options.configFile)
	config.PushdConf = new(config.ConfigPushd)
	config.PushdConf.LoadConfig(conf)

	engine.PubsubChannels = engine.NewPubsubChannels(config.PushdConf.PubsubChannelMaxItems)

	signal.RegisterSignalHandler(syscall.SIGINT, func(sig os.Signal) {
		shutdown()
	})
}