示例#1
0
 def stop(self):
     if self.Has(self.name):
         # This sends a Ctrl-C.
         Tmux.Write(self.name, "daemon", "C-c")
         # If the window does not become responsive after 5s, we kill the
         # window.
         if not Tmux.IsResponsive(self.name, "daemon", timeout=5):
             Tmux.KillWindow(self.name, "daemon")
         return True
     else:
         return False
示例#2
0
 def start(self, command=None):
     command = command or self.command
     if not self.Has(self.name):
         Tmux.EnsureSession(self.name)
         Tmux.EnsureWindow(self.name, "daemon")
     if Tmux.IsResponsive(self.name, "daemon"):
         if not command:
             command = Tmux.Run(self.name, "daemon", "echo $DAEMON_COMMAND")
         # We assume that the daemon's will not detach from tmux, so if
         # the shell is not responsive, it means the daemon is running
         Tmux.Write(
             self.name, "daemon", "export DAEMON_COMMAND=\"{0}\"".format(
                 command.replace('"', '\\"')))
         Tmux.Write(self.name, "daemon", command)
     return True
示例#3
0
 def ensure(self):
     """Ensures that the service is running."""
     session = self.config["session"]
     path = os.path.abspath(self.config["path"])
     Tmux.EnsureWindow(session, "webapp")
     if Tmux.IsResponsive(session, "webapp"):
         # If the Tmux session is responsive, we start the process
         Tmux.Run(session, "webapp", "cd {0}".format(path))
         Tmux.Run(session, "webapp",
                  "./env.sh ./{webapp} {port} {host}".format(**self.config))
     elif not self.ping().isSuccess():
         # If the Tmux session is not responsive and the ping does not work
         # we kill and restart the process.
         self.reload()
     return self.process()