- command = environ + command
- command = self.replace_paths(command)
-
- x11 = self.get("forwardX11")
-
- # We save the reference to the process in self._proc
- # to be able to kill the process from the stop method
- (out, err), self._proc = self.node.execute(command,
- sudo = sudo,
- stdin = stdin,
- forward_x11 = x11,
- blocking = False)
-
- if self._proc.poll():
- out = ""
- err = self._proc.stderr.read()
- self._state = ResourceState.FAILED
- self.error(msg, out, err)
- raise RuntimeError, msg
-
- super(LinuxApplication, self).start()
-
- elif command:
- # If command is set (i.e. application not used only for dependency
- # installation), and it does not need to run in foreground, we use
- # the 'run' method of the node to launch the application as a daemon
-
- # The real command to execute was previously uploaded to a remote bash
- # script during deployment, now run the remote script using 'run' method
- # from the node
- cmd = "bash ./app.sh"
- (out, err), proc = self.node.run(cmd, self.app_home,
- stdin = stdin,
- stdout = stdout,
- stderr = stderr,
- sudo = sudo)
-
- # check if execution errors occurred
- msg = " Failed to start command '%s' " % command
-
- if proc.poll() and err:
- self.error(msg, out, err)
- raise RuntimeError, msg
-
- # Check status of process running in background
- pid, ppid = self.node.wait_pid(self.app_home)
- if pid: self._pid = int(pid)
- if ppid: self._ppid = int(ppid)
-
- # If the process is not running, check for error information
- # on the remote machine
- if not self.pid or not self.ppid:
- (out, err), proc = self.node.check_output(self.app_home, 'stderr')
- self.error(msg, out, err)