Example #1
0
/*
	cliOpts    : extra options
	configFile : gnatsd config file
	routes     : cluster members
*/
func NewGnatsdServer(cliOpts server.Options, configFile string, routeHosts []string, log server.Logger) (s *server.Server, opts *server.Options, err error) {
	log.Noticef("gnatsd config file: %s\n", configFile)
	// Configure options based on config file
	if opts, err = configureServerOptions(&cliOpts, configFile, routeHosts); err != nil {
		return
	}
	log.Debugf("Adding routes: %v\n", opts.Routes)
	// Create the server with appropriate options.
	s = server.New(opts)

	// Configure the authentication mechanism
	configureAuth(s, opts)

	s.SetLogger(log, opts.Debug, opts.Trace)

	return
}