Esempio n. 1
0
 def stop(self):
     session = self.config["session"]
     Tmux.EnsureWindow(session, "webapp")
     p = Process.FindLike(self.config["webapp"])
     # We kill the whole process group
     if p: Process.Kill(p[0], children=True)
     return self.process()
Esempio n. 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
Esempio n. 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()