本文整理匯總了Golang中github.com/funkygao/log4go.Info函數的典型用法代碼示例。如果您正苦於以下問題:Golang Info函數的具體用法?Golang Info怎麽用?Golang Info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Info函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: shutdown
func (this *Start) shutdown() {
// kill haproxy
log.Info("killling haproxy processes")
f, e := os.Open(haproxyPidFile)
if e != nil {
log.Error("shutdown %v", e)
return
}
reader := bufio.NewReader(f)
for {
l, e := gio.ReadLine(reader)
if e != nil {
// EOF
break
}
pid, _ := strconv.Atoi(string(l))
p := &os.Process{
Pid: pid,
}
if err := p.Kill(); err != nil {
log.Error(err)
} else {
log.Info("haproxy[%d] terminated", pid)
}
}
log.Info("removing %s", haproxyPidFile)
os.Remove(haproxyPidFile)
}
示例2: Main
func (this *Mirror) Main() (exitCode int) {
this.quit = make(chan struct{})
signal.RegisterHandler(func(sig os.Signal) {
log.Info("received signal: %s", strings.ToUpper(sig.String()))
log.Info("quiting...")
this.once.Do(func() {
close(this.quit)
})
}, syscall.SIGINT, syscall.SIGTERM)
limit := (1 << 20) * this.BandwidthLimit / 8
if this.BandwidthLimit > 0 {
this.bandwidthRateLimiter = ratelimiter.NewLeakyBucket(limit*10, time.Second*10)
}
log.Info("starting [email protected]%s", gafka.BuildId)
// pprof
debugAddr := ":10009"
go http.ListenAndServe(debugAddr, nil)
log.Info("pprof ready on %s", debugAddr)
z1 := zk.NewZkZone(zk.DefaultConfig(this.Z1, ctx.ZoneZkAddrs(this.Z1)))
z2 := zk.NewZkZone(zk.DefaultConfig(this.Z2, ctx.ZoneZkAddrs(this.Z2)))
c1 := z1.NewCluster(this.C1)
c2 := z2.NewCluster(this.C2)
this.runMirror(c1, c2, limit)
log.Info("bye [email protected]%s, %s", gafka.BuildId, time.Since(this.startedAt))
log.Close()
return
}
示例3: Start
func (this *mysqlStore) Start() error {
if err := this.refreshFromMysql(); err != nil {
// refuse to start if mysql conn fails
return err
}
// TODO watch KatewayMysqlDsn znode
go func() {
ticker := time.NewTicker(this.cf.Refresh)
defer ticker.Stop()
for {
select {
case <-ticker.C:
this.refreshFromMysql()
log.Info("manager refreshed from mysql")
case <-this.refreshCh:
this.refreshFromMysql()
log.Info("manager forced to refresh from mysql")
case <-this.shutdownCh:
log.Info("mysql manager stopped")
return
}
}
}()
return nil
}
示例4: Start
func (this *Monitor) Start() {
this.leader = true
this.leadAt = time.Now()
this.stop = make(chan struct{})
go func() {
log.Info("telemetry started: %s", telemetry.Default.Name())
if err := telemetry.Default.Start(); err != nil {
log.Error("telemetry: %v", err)
}
}()
this.inflight = new(sync.WaitGroup)
this.watchers = this.watchers[:0]
for name, watcherFactory := range registeredWatchers {
watcher := watcherFactory()
this.watchers = append(this.watchers, watcher)
watcher.Init(this)
log.Info("created and starting watcher: %s", name)
this.inflight.Add(1)
go watcher.Run()
}
log.Info("all watchers ready!")
<-this.stop
this.inflight.Wait()
log.Info("all watchers stopped")
}
示例5: reloadHAproxy
func (this *Start) reloadHAproxy() (err error) {
var cmd *exec.Cmd = nil
waitStartCh := make(chan struct{})
if this.starting {
log.Info("haproxy starting")
cmd = exec.Command(this.command, "-f", configFile) // TODO use absolute path
this.starting = false
go func() {
<-waitStartCh
log.Info("haproxy started")
if err := cmd.Wait(); err != nil {
log.Error("haproxy: %v", err)
}
}()
} else {
shellScript := fmt.Sprintf("%s -f %s/%s -sf `cat %s/%s`",
this.command, this.root, configFile, this.root, haproxyPidFile)
log.Info("haproxy reloading: %s", shellScript)
cmd = exec.Command("/bin/sh", "-c", shellScript)
go func() {
<-waitStartCh
log.Info("haproxy reloaded")
if err := cmd.Wait(); err != nil {
log.Error("haproxy: %v", err)
}
}()
}
if err = cmd.Start(); err == nil {
waitStartCh <- struct{}{}
}
return err
}
示例6: Start
func (this *mysqlStore) Start() error {
if err := this.refreshFromMysql(); err != nil {
// refuse to start if mysql conn fails
return fmt.Errorf("manager[%s]: %v", this.Name(), err)
}
go func() {
ticker := time.NewTicker(this.cf.Refresh)
defer ticker.Stop()
for {
select {
case <-ticker.C:
if err := this.refreshFromMysql(); err != nil {
log.Error(err.Error())
} else {
log.Info("manager refreshed from mysql")
}
case <-this.refreshCh:
if err := this.refreshFromMysql(); err != nil {
log.Error(err.Error())
} else {
log.Info("manager forced to refresh from mysql")
}
case <-this.shutdownCh:
log.Info("mysql manager stopped")
return
}
}
}()
return nil
}
示例7: addPartition
func (this *Partition) addPartition(zkAddrs string, topic string, partitions int) error {
log.Info("adding partitions to topic: %s", topic)
cmd := pipestream.New(fmt.Sprintf("%s/bin/kafka-topics.sh", ctx.KafkaHome()),
fmt.Sprintf("--zookeeper %s", zkAddrs),
fmt.Sprintf("--alter"),
fmt.Sprintf("--topic %s", topic),
fmt.Sprintf("--partitions %d", partitions),
)
err := cmd.Open()
if err != nil {
return err
}
scanner := bufio.NewScanner(cmd.Reader())
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
this.Ui.Output(color.Yellow(scanner.Text()))
}
err = scanner.Err()
if err != nil {
return err
}
cmd.Close()
log.Info("added partitions to topic: %s", topic)
return nil
}
示例8: loadTemplates
func loadTemplates() {
if config.faeTemplateFile != "" {
body, err := ioutil.ReadFile(config.faeTemplateFile)
if err != nil {
log.Error("template[%s]: %s", config.faeTemplateFile, err)
} else {
faeTemplateContents = string(body)
log.Info("template[%s] loaded", config.faeTemplateFile)
}
}
if config.actorTemplateFile != "" {
body, err := ioutil.ReadFile(config.actorTemplateFile)
if err != nil {
log.Error("template[%s]: %s", config.actorTemplateFile, err)
} else {
maintainTemplateContents = string(body)
log.Info("template[%s] loaded", config.actorTemplateFile)
}
}
if config.maintainTemplateFile != "" {
body, err := ioutil.ReadFile(config.maintainTemplateFile)
if err != nil {
log.Error("template[%s]: %s", config.maintainTemplateFile, err)
} else {
maintainTemplateContents = string(body)
log.Info("template[%s] loaded", config.maintainTemplateFile)
}
}
}
示例9: shutdown
func shutdown() {
log.Info("unregistering etcd")
engineRunner.UnregisterEtcd()
cleanup()
log.Info("Terminated")
os.Exit(0)
}
示例10: main
func (this *Start) main() {
ctx.LoadFromHome()
this.zkzone = zk.NewZkZone(zk.DefaultConfig(this.zone, ctx.ZoneZkAddrs(this.zone)))
zkConnEvt, ok := this.zkzone.SessionEvents()
if !ok {
panic("someone stealing my events")
}
registry.Default = zkr.New(this.zkzone)
log.Info("ehaproxy[%s] starting...", gafka.BuildId)
go this.runMonitorServer(this.httpAddr)
zkConnected := false
for {
instances, instancesChange, err := registry.Default.WatchInstances()
if err != nil {
log.Error("zone[%s] %s", this.zkzone.Name(), err)
time.Sleep(time.Second)
continue
}
if zkConnected {
if len(instances) > 0 {
this.reload(instances)
} else {
// resilience to zk problem by local cache
log.Warn("backend all shutdown? skip this change")
time.Sleep(time.Second)
continue
}
}
select {
case <-this.quitCh:
return
case evt := <-zkConnEvt:
if evt.State == zklib.StateHasSession && !zkConnected {
log.Info("zk connected")
zkConnected = true
} else if zkConnected {
log.Warn("zk jitter: %+v", evt)
}
case <-instancesChange:
log.Info("instances changed!!")
}
}
}
示例11: StopRpcServe
func (this *Engine) StopRpcServe() {
log.Info("RPC server stopping...")
rpcServer := this.rpcServer.(*TFunServer)
rpcServer.Stop()
close(this.stopChan)
outstandingSessions := atomic.LoadInt64(&rpcServer.activeSessionN)
log.Warn("RPC outstanding sessions: %d", outstandingSessions)
this.svt.Flush()
log.Info("RPC server stopped gracefully")
}
示例12: RunForever
func (this *controller) RunForever() (err error) {
log.Info("controller[%s] starting", this.Id())
if err = this.orchestrator.RegisterActor(this.Id(), this.Bytes()); err != nil {
return err
}
defer this.orchestrator.ResignActor(this.Id())
if err = manager.Default.Start(); err != nil {
return
}
log.Trace("manager[%s] started", manager.Default.Name())
go this.runWebServer()
jobDispatchQuit := make(chan struct{})
go this.dispatchJobQueues(jobDispatchQuit)
webhookDispatchQuit := make(chan struct{})
go this.dispatchWebhooks(webhookDispatchQuit)
select {
case <-jobDispatchQuit:
log.Warn("dispatchJobQueues quit")
case <-webhookDispatchQuit:
log.Warn("dispatchWebhooks quit")
}
manager.Default.Stop()
log.Trace("manager[%s] stopped", manager.Default.Name())
return
}
示例13: discoverPeers
func (this *Peer) discoverPeers() {
defer func() {
this.c.Close() // leave the multicast group
}()
var msg peerMessage
reader := bufio.NewReader(this.c)
for {
// net.ListenMulticastUDP sets IP_MULTICAST_LOOP=0 as
// default, so you never receive your own sent data
// if you run both sender and receiver on (logically) same IP host
line, _, err := reader.ReadLine()
if err != nil {
log.Error(err)
continue
}
if err := msg.unmarshal(line); err != nil {
// Not our protocol, it may be SSDP or else
continue
}
log.Debug("received peer: %+v", msg)
neighborIp, present := msg["ip"]
if !present {
log.Info("Peer msg has no 'ip'")
continue
}
this.refreshNeighbor(neighborIp.(string))
}
}
示例14: Run
func (this *WatchActord) Run() {
defer this.Wg.Done()
ticker := time.NewTicker(this.Tick)
defer ticker.Stop()
jobQueues := metrics.NewRegisteredGauge("actord.jobqueues", nil)
actors := metrics.NewRegisteredGauge("actord.actors", nil)
orphan := metrics.NewRegisteredGauge("actord.orphan", nil)
backlog := metrics.NewRegisteredGauge("actord.backlog.30s", nil)
archive := metrics.NewRegisteredGauge("actord.archive.30s", nil)
webhooks := metrics.NewRegisteredGauge("actord.webhooks", nil)
for {
select {
case <-this.Stop:
log.Info("%s stopped", this.ident())
return
case now := <-ticker.C:
jLen, aLen, orphanN, backlogN, archiveN := this.watchJobs(now)
jobQueues.Update(jLen)
actors.Update(aLen)
orphan.Update(orphanN)
backlog.Update(backlogN)
archive.Update(archiveN)
this.watchWebhooks(webhooks, now)
}
}
}
示例15: RefreshBrokerList
// TODO from live meta or zk?
func (this *pubPool) RefreshBrokerList(brokerList []string) {
if len(brokerList) == 0 {
if len(this.brokerList) > 0 {
log.Warn("%s meta store found empty broker list, refresh refused", this.cluster)
}
return
}
setOld, setNew := set.NewSet(), set.NewSet()
for _, b := range this.brokerList {
setOld.Add(b)
}
for _, b := range brokerList {
setNew.Add(b)
}
if !setOld.Equal(setNew) {
log.Info("%s broker list from %+v to %+v", this.cluster, this.brokerList, brokerList)
// rebuild the kafka conn pool
this.brokerList = brokerList
this.Close()
this.buildPools()
}
}