示例#1
0
func envOpts() (opts []string) {
	for _, env := range cfg.Env {
		opts = append(opts, "-e", env)
	}

	old_cfg := cfg
	old_process := process

	for _, process := range config.List() {
		settings := config.Process(process)
		if settings.IncludeEnv {
			SetProcess(process)
			SetConfig(config.Process(process))

			for i := 0; i < cfg.Instances; i++ {
				if running() {
					net := networkSettings(i)
					name := fmt.Sprintf("%s_%d_IP=%s", process, i, net.Ip)
					opts = append(opts, "-e", strings.ToUpper(name))
					name = fmt.Sprintf("%s_%d_PORT=%s", process, i, net.Private.tcp)
					opts = append(opts, "-e", strings.ToUpper(name))
				}
			}
		}
	}

	cfg = old_cfg
	process = old_process
	return
}
示例#2
0
// handleCommand will take in the argument for the process and run it
func ParseCommand(args []string) {
	SetProcess(args[0])
	SetConfig(config.Process(args[0]))
	opts := commandOpts(args)

	if message, ok := cfg.Valid(); ok {

		name := args[1]
		daemonCmd, daemonOk := DaemonizedCommands()[name]
		infoCmd, infoOk := InfoCommands()[name]
		interactiveCmd, interactiveOk := InteractiveCommands()[name]

		switch {
		case daemonOk:
			daemonCmd.run(opts...)
		case infoOk:
			infoCmd.run(opts...)
		case interactiveOk:
			interactiveCmd.run(opts...)
		default:
			logger.Log(fmt.Sprintf("Running Command: (%v) doesn't exists\n", args[1]))
		}
	} else {
		logger.Log(message)
	}

}
示例#3
0
func BundleInstall(args ...string) {
	if cfg == nil {
		config.LoadConfigs()
		for _, process := range config.List() {
			SetProcess(process)
			SetConfig(config.Process(process))
			BundleInstall(args...)
		}
	} else if cfg.UseBundler {
		runExec("bundle", "install", "--path", ".gems")
	}
}
示例#4
0
func postUpdate() {
	if cfg == nil {
		config.LoadConfigs()
		for _, process := range config.List() {
			SetProcess(process)
			SetConfig(config.Process(process))
			postInstall()
		}
	} else if cfg.PostUpdate != "" {
		cmd := exec.Command(cfg.PostUpdate)
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr
		cmd.Run()
	}
}
示例#5
0
// Build will create the container if nessary
func Build(args ...string) {
	wd, _ := os.Getwd()
	logger.Log(fmt.Sprintf("In %s to build.", wd))
	if cfg != nil {
		logger.Log(fmt.Sprintf("Building...%s\n", cfg.App))
		cmd := exec.Command("docker", "build", "-t", cfg.Container, cfg.BuildFile)
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr
		cmd.Stdin = os.Stdin
		cmd.Run()
	} else {
		config.LoadConfigs()
		for _, process := range config.List() {
			SetProcess(process)
			SetConfig(config.Process(process))
			Build(args...)
		}
	}
}