func (this *Sheep) Stop() (err error) { if this.cmd.Process == nil { return errors.New(fmt.Sprintf("%s not started.", this.Name)) } if this.cmd.ProcessState == nil { log.Log("process state unvailable") } else if this.cmd.ProcessState.Exited() { return errors.New(fmt.Sprintf("%s has stoped.", this.Name)) } this.Status = constant.STATUS_STOPING log.Logf("signal:%d", this.StopSignal) if err = this.cmd.Process.Signal(syscall.Signal(this.StopSignal)); err == nil { this.Status = constant.STATUS_STOPPED } else { log.Error("stop faild:", err.Error()) } return err }
func NewHttpServe(conf Config, leader string) (err error) { var server = new(httpServer) // 初始化daemon配置 if err = conf.DaemonBase.InitAll(); err != nil { log.Noticef("new http serve daemon base init faild: %+v --- %s\n ", conf.DaemonBase, err.Error()) return } server.DaemonBase = conf.DaemonBase // 初始化collie配置 server.ctx = NewContex() if err = server.ctx.LoadConfig(conf.ContexConfig); err != nil { log.Errorf("new http serve contex init faild: %+v\n", conf) return } // 初始化http配置 if err = conf.Http.Check(); err != nil { log.Noticef("new http serve net base init faild: %+v --- %s\n ", conf, err.Error()) return } server.NetBase = conf.Http if server.elect, err = NewElectServer(conf, leader); err != nil { log.Error("new elect server faild : ", err.Error()) return } // 持久化配置 if err = server.Persistence(); err != nil { log.Errorf("persistence faild : %s", err.Error()) return } // 启动http服务 err = conf.Http.StartHttp(server) return }