Exemplo n.º 1
0
Arquivo: run.go Projeto: kelyar/clio
/**
 *  High-level abstraction for running processes
 *  (called from cli.Route())
 */
func Run() {
	if _, err := os.Stat(Procfile); os.IsNotExist(err) {
		fmt.Println(red, "error:", reset, Procfile, "doesn't exist")
		os.Exit(1)
	}

	helpers.ApplicationRebuild() // sync

	// starting up tcp server, needed for hotswap
	go LaunchTcpServer()

	list := ProcessList{processes: listProcesses()}
	list.spawnAll()
}
Exemplo n.º 2
0
func (t *Server) RelaunchProcess(args *Args, reply *int) error {
	if RelaunchProcessFlag {
		RelaunchProcessFlag = false
		appProc := LaunchedProcesses[applicationProcessCode]

		// backupig application's process info
		processBackup := BackupProcess(appProc)

		// killing old app's process
		err := appProc.Process.Kill()
		if err != nil {
			log.Fatal("cli.RelaunchProcess()#54:", err) /////////// debug
		}
		appProc.Process.Kill()

		// rebuilding application
		helpers.ApplicationRebuild() // sync

		// Relaunch application
		newApplicationProc := exec.Command(processBackup.Path, processBackup.Args...)

		// streaming output from new app instance
		stdOut, _ := newApplicationProc.StdoutPipe()
		stdErr, _ := newApplicationProc.StderrPipe()

		go StreamOutput(stdOut, stdErr, applicationProcessCode)

		go newApplicationProc.Start()

		// updating `LaunchedProcesses`
		LaunchedProcesses[applicationProcessCode] = newApplicationProc
		RelaunchProcessFlag = true
	}

	return nil
}