示例#1
0
文件: divert.go 项目: akaspin/bar
// Abort diversion
func (d *Divert) Cleanup(spec DivertSpec) (err error) {
	// Remove orphan diverted files
	orphans := map[string]struct{}{}
	for _, f := range spec.TargetFiles {
		orphans[f] = struct{}{}
	}
	for _, f := range spec.ToRecover {
		_, ok := orphans[f]
		if ok {
			delete(orphans, f)
		}
	}
	for f, _ := range orphans {
		os.Remove(lists.OSFromSlash(lists.OSJoin(d.Git.Root, f)))
		logx.Debugf("removed orphan %s", f)
	}

	// Reset to Head
	if err = d.Git.Reset(spec.Head); err != nil {
		return
	}

	if err = d.Git.Checkout(spec.Head, spec.ToRecover...); err != nil {
		return
	}

	logx.Info("cleanup finished")
	return
}
示例#2
0
文件: ping.go 项目: pombredanne/bar
func (c *PingCmd) Run(args ...string) (err error) {
	var mod *model.Model
	if mod, err = model.New(c.WD, false, c.ChunkSize, c.PoolSize); err != nil {
		return
	}
	trans := transport.NewTransport(mod, "", c.Endpoint, c.PoolSize)
	res, err := trans.ServerInfo()
	logx.Info(res)
	return
}
示例#3
0
文件: divert.go 项目: akaspin/bar
// Begin diversion to on branch where "names"
// is git-specific <tree-ish>
func (d *Divert) Begin(spec DivertSpec) (err error) {

	if err = d.writeSpec(spec); err != nil {
		return
	}

	// OOOK!!! Let's play with hammer!
	if err = d.Git.Reset(spec.TargetBranch); err != nil {
		return
	}

	if err = d.Git.Checkout(spec.TargetBranch, spec.TargetFiles...); err != nil {
		return
	}

	logx.Info("DIVERSION IN PROGRESS! DO NOT use any git commands!")
	return
}
示例#4
0
文件: wavesd.go 项目: tamtam-im/waves
func main() {
	flags.New().SetPrefix("WAVES").Boot()
	logx.SetLevel(log_level)

	ctx, cancel := context.WithCancel(context.Background())

	mach := machine.NewMachine(ctx, interval)
	go mach.Start()

	datapointReporter := datapoint.NewReporter(&datapointOptions, noop)

	u, err := url.Parse(annotationsEndpoint)
	logx.OnFatal(err)
	if token != "" {
		u.User = url.User(token)
	}
	annReporter := annotation.NewReporter(&annotation.ReporterOptions{u}, noop)

	dp := dockerprobe.NewDockerProbe(dockerEndpoint,
		makeDockerReporter(datapointReporter),
		report.NewMetaReporter(strings.Split(dockerAnnotationTags, ","),
			annReporter),
	)
	err = mach.Add(dp)
	logx.OnFatal(err)

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)
	<-sigChan
	logx.Info("bye")
	cancel()
}