Beispiel #1
0
func initConfig(config *script.Config, a *api) {
	config.Snapshot = a.AddSnapshot
	config.Restore = a.Rollback
	config.TenantLookup = cliTenantLookup(a)
	config.SvcIDFromPath = cliServiceIDFromPath(a)
	config.SvcStart = cliServiceControl(a.StartService)
	config.SvcStop = cliServiceControl(a.StopService)
	config.SvcRestart = cliServiceControl(a.RestartService)
	config.SvcWait = cliServiceWait(a)
	config.Commit = a.Commit
	config.SvcUse = cliServiceUse(a)
}
Beispiel #2
0
func runScript(c *ServicedCli, ctx *cli.Context, fileName string, config *script.Config) {
	stopChan := make(chan struct{})
	signalHandlerChan := make(chan os.Signal)
	signal.Notify(signalHandlerChan, syscall.SIGINT, syscall.SIGTERM)
	go func() {
		<-signalHandlerChan
		glog.Infof("Received stop signal, stopping")
		close(stopChan)
	}()

	config.NoOp = ctx.Bool("no-op")
	config.DockerRegistry = docker.DEFAULT_REGISTRY
	err := c.driver.ScriptRun(fileName, config, stopChan)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		c.exit(1)
		return
	}
}