Example #1
0
			if jq == nil {
				die("according to the pid file %s, wr manager for port %s was running with pid %d, but that process could not be terminated and the manager could not be connected to; most likely the pid file is wrong and the manager is not running - after confirming, delete the pid file before trying to start the manager again", config.ManagerPidFile, config.ManagerPort, pid)
			}
		}

		// we managed to connect to the daemon; get it's real pid and try to
		// stop it again
		sstats, err := jq.ServerStats()
		if err != nil {
			die("even though I was able to connect to the manager, it failed to tell me its true pid; giving up trying to stop it")
		}

		// though it may actually be running on a remote host and we managed to
		// connect to it via ssh port forwarding; compare the server ip to our
		// own
		myAddr := jobqueue.CurrentIP() + ":" + config.ManagerPort
		sAddr := sstats.ServerInfo.Addr
		if myAddr == sAddr {
			jq.Disconnect()
			stopped = stopdaemon(sstats.ServerInfo.PID, "the manager itself", "manager")
		} else {
			// use the client command to stop it
			stopped = jq.ShutdownServer()

			// since I don't trust using a client connection to shut down the
			// server, double check I can no longer connect
			if stopped {
				jq = connect(1 * time.Second)
				if jq != nil {
					warn("I requested shut down of the remote manager at %s, but it still up!", sAddr)
					stopped = false
Example #2
0
File: add.go Project: sb10/vrpipe
			defer reader.(*os.File).Close()
		}

		// we'll default to pwd if the manager is on the same host as us, /tmp
		// otherwise
		jq, err := jobqueue.Connect(addr, "cmds", timeout)
		if err != nil {
			die("%s", err)
		}
		sstats, err := jq.ServerStats()
		if err != nil {
			die("even though I was able to connect to the manager, it failed to tell me its location")
		}
		var pwd string
		var pwdWarning int
		if jobqueue.CurrentIP()+":"+config.ManagerPort == sstats.ServerInfo.Addr {
			pwd, err = os.Getwd()
			if err != nil {
				die("%s", err)
			}
		} else {
			pwd = "/tmp"
			pwdWarning = 1
		}
		jq.Disconnect()

		// for network efficiency, read in all commands and create a big slice
		// of Jobs and Add() them in one go afterwards
		var jobs []*jobqueue.Job
		scanner := bufio.NewScanner(reader)
		defaultedRepG := false