func IsDevelopmentEnvironment(deploymentName string) (devEnv bool) {
	if len(deploymentName) == 0 || strings.ToLower(deploymentName) == "development" {
		devEnv = true
	}
	return
}
IsDevelopmentEnvironment detects if we are running in a development environment
package common
import (
	"fmt"
	"math/rand"
	"net/http"
	"os"
	"strings"
	"time"
	log "github.com/sirupsen/logrus"
	"github.com/uber-common/bark"
	"github.com/uber/cherami-server/common/configure"
	dconfig "github.com/uber/cherami-server/common/dconfigclient"
	"github.com/uber/cherami-server/common/metrics"
	"github.com/uber/cherami-thrift/.generated/go/controller"
	"github.com/uber/tchannel-go"
	"github.com/uber/tchannel-go/thrift"
)
const roleKey = "serviceName"
func NewService(serviceName string, uuid string, cfg configure.CommonServiceConfig, resolver UUIDResolver, hostHWInfoReader HostHardwareInfoReader, reporter metrics.Reporter, dClient dconfig.Client, authManager AuthManager) *Service {
	sVice := &Service{
		sName:                  serviceName,
		cfg:                    cfg,
		resolver:               resolver,
		hostHWInfoReader:       hostHWInfoReader,
		hostUUID:               uuid,
		bLimitsEnabled:         true,  
		mReporter:              reporter,
		runtimeMetricsReporter: metrics.NewRuntimeMetricsReporter(reporter, time.Minute, cfg.GetLogger()),
		dClient:                dClient,
		authManager:            authManager,
	}
	if hostName, e := os.Hostname(); e != nil {
		log.Fatal("Error getting hostname")
	} else {
		sVice.hostName = hostName
	}
	sVice.startWg.Add(1)
	return sVice
}
func (h *Service) UpdateAdvertisedName(deploymentName string) {
	if h.sName == FrontendServiceName {
		if IsDevelopmentEnvironment(deploymentName) {
			h.sName = FrontendServiceName
		} else {
			parts := strings.Split(deploymentName, "_")
			if len(parts) != 2 {
				log.Fatal("Unexpected deployment name")
			}
			tenancy := strings.ToLower(parts[0])
			if tenancy == TenancyProd {
				h.sName = FrontendServiceName
			} else {
				h.sName = fmt.Sprintf("%v_%v", FrontendServiceName, tenancy)
			}
		}
	}
}
func (h *Service) GetTChannel() *tchannel.Channel {
	h.startWg.Wait()
	return h.ch
}
func (h *Service) GetConfig() configure.CommonServiceConfig {
	return h.cfg
}
func (h *Service) GetRingpopMonitor() RingpopMonitor {
	h.startWg.Wait()
	return h.rpm
}
func (h *Service) GetClientFactory() ClientFactory {
	h.startWg.Wait()
	return h.cFactory
}
func (h *Service) SetClientFactory(cf ClientFactory) {
	h.cFactory = cf
}
func (h *Service) GetWSConnector() WSConnector {
	h.startWg.Wait()
	return h.wsConnector
}
func (h *Service) GetLoadReporterDaemonFactory() LoadReporterDaemonFactory {
	h.startWg.Wait()
	return h.rFactory
}
func (h *Service) GetHostPort() string {
	h.startWg.Wait()
	return h.hostPort
}
func (h *Service) GetHostName() string {
	return h.hostName
}
func (h *Service) GetHostUUID() string {
	return h.hostUUID
}
func (h *Service) GetMetricsReporter() metrics.Reporter {
	return h.mReporter
}
func (h *Service) IsLimitsEnabled() bool {
	return h.bLimitsEnabled
}
func (h *Service) GetDConfigClient() dconfig.Client {
	return h.dClient
}
func (h *Service) Start(thriftServices []thrift.TChanServer) {
	h.GetMetricsReporter().InitMetrics(metrics.ServiceMetrics)
	h.GetMetricsReporter().IncCounter(metrics.RestartCount, nil, 1)
	h.runtimeMetricsReporter.Start()
	h.ch, h.server = h.cfg.SetupTChannelServer(h.sName, thriftServices)
	h.logger = h.cfg.GetLogger()
	h.bLimitsEnabled = h.cfg.GetLimitsEnabled()
	h.hostPort = h.ch.PeerInfo().HostPort
	host, port, _ := SplitHostPort(h.hostPort)
	h.rp = CreateRingpop(h.sName, h.ch, host, port)
	if h.rp == nil {
		h.logger.Fatal("Ringpop creation failed")
	}
	err := BootstrapRingpop(h.rp, host, port, h.cfg)
	if err != nil {
		h.logger.WithFields(bark.Fields{TagErr: err}).Fatal("Ringpop bootstrap failed")
	}
	h.rpm = NewRingpopMonitor(h.rp, services, h.resolver, h.hostHWInfoReader, h.logger)
	if err = h.rpm.SetMetadata(roleKey, h.sName); err != nil {
		h.logger.WithFields(bark.Fields{TagErr: err}).Fatal("Ringpop setting role label failed")
	}
	h.rpm.Start()
	h.cFactory = NewClientFactory(h.rpm, h.ch, h.logger)
	h.wsConnector = NewWSConnector()
	lg := h.logger.WithField(TagService, FmtService(h.sName)).WithField(TagHostPort, FmtHostPort(h.hostPort))
	h.rFactory = NewLoadReporterDaemonFactory(h.hostUUID, controller.SKU_Machine1, controller.Role_IN, h.cFactory,
		NewRealTimeTickerFactory(), NewTokenBucketFactory(), lg)
	lg.Info("service started")
	rand.Seed(time.Now().UTC().UnixNano())
	h.startWg.Done()
}
func (h *Service) Stop() {
	if h.rpm != nil {
		h.rpm.Stop()
	}
	if h.rp != nil {
		h.rp.Destroy()
	}
	if h.ch != nil {
		h.ch.Close()
	}
	h.runtimeMetricsReporter.Stop()
}
func (h *Service) Report(reporter LoadReporter) {
}
func (h *Service) UpgradeHandler(w http.ResponseWriter, r *http.Request) {
}
func (h *Service) GetAuthManager() AuthManager {
	return h.authManager
}