コード例 #1
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()
コード例 #2
0
ファイル: service.py プロジェクト: davergarag/monitoring
 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 reload(self):
     self.stop()
     session = self.config["session"]
     Tmux.Run(session, "webapp",
              "./env.sh ./{webapp} {port} {host}".format(**self.config))
     return self.process()