예제 #1
0
def main():

    signal.signal(signal.SIGINT, exit_handler)

    watchdog = WatchDog()

    tincan_path = CONFIG["tincan_path"]

    if os.path.exists(tincan_path):
        tincan_bin = os.path.abspath(tincan_path)

        with open("core_log", "w+") as core_log:
            logging.debug("Starting ipop-tincan")
            tincan_process = subprocess.Popen([tincan_bin],
                                              stdout=subprocess.PIPE,
                                              stderr=core_log)
            time.sleep(1)

    else:
        logging.debug("TinCan binary doesn't exist at specified directory")
        sys.exit(0)

    server = UdpServer(CONFIG["xmpp_username"], CONFIG["xmpp_password"],
                       CONFIG["xmpp_host"], CONFIG["ip4"])

    run_event.set()
    t = threading.Thread(target=server.run_server)

    logging.debug("Starting Server")
    t.daemon = True
    t.start()
    last_time = time.time()
    watchdog.inactive_time = time.time()
    tincan_attempt = 0

    logging.debug("Starting WatchDog")
    while run_event.is_set():
        try:
            watchdog.watch()
            time_diff = time.time() - last_time
            if time_diff > CONFIG["wait_time"]:
                logging.debug("watchdog send_get_state")
                gvpn.do_get_state(watchdog.sock)
                last_time = time.time()
        except TinCanException:
            tincan_attempt += 1
            logging.error("TinCan Failed {0} times".format(tincan_attempt))
            os.kill(tincan_process.pid, signal.SIGTERM)
            time.sleep(1)
            if tincan_attempt > 3:
                logging.critical("TinCan Failed beyond threshold point")
                run_event.clear()
                break
            with open("core_log", "wb+") as core_log:
                tincan_process = subprocess.Popen([tincan_bin],
                                                  stdout=subprocess.PIPE,
                                                  stderr=core_log)
                time.sleep(1)
            server.ctrl_conn_init()
            watchdog.inactive_time = time.time()
def main():

    signal.signal(signal.SIGINT, exit_handler)

    watchdog = WatchDog()

    tincan_path = CONFIG["tincan_path"]

    if os.path.exists(tincan_path):
        tincan_bin = os.path.abspath(tincan_path)

        with open("core_log", "w+") as core_log:
            logging.debug("Starting ipop-tincan");
            tincan_process = subprocess.Popen([tincan_bin], 
                    stdout=subprocess.PIPE, stderr=core_log)
            time.sleep(1)

    else:
        logging.debug("TinCan binary doesn't exist at specified directory")
        sys.exit(0)

    server = UdpServer(CONFIG["xmpp_username"], CONFIG["xmpp_password"],
                     CONFIG["xmpp_host"], CONFIG["ip4"])

    
    run_event.set()
    t = threading.Thread(target=server.run_server)

    logging.debug("Starting Server");
    t.daemon = True
    t.start()
    last_time = time.time()
    watchdog.inactive_time = time.time()
    tincan_attempt = 0

    logging.debug("Starting WatchDog");
    while run_event.is_set():
        try:
            watchdog.watch()
            time_diff = time.time() - last_time
            if time_diff > CONFIG["wait_time"]:
                logging.debug("watchdog send_get_state")
                gvpn.do_get_state(watchdog.sock)
                last_time = time.time()
        except TinCanException:
            tincan_attempt += 1
            logging.error("TinCan Failed {0} times".format(tincan_attempt));
            os.kill(tincan_process.pid, signal.SIGTERM)
            time.sleep(1)
            if tincan_attempt > 3:
                logging.critical("TinCan Failed beyond threshold point");
                run_event.clear()
                break
            with open("core_log", "wb+") as core_log:
                tincan_process = subprocess.Popen([tincan_bin], 
                        stdout=subprocess.PIPE, stderr=core_log)
                time.sleep(1)
            server.ctrl_conn_init()
            watchdog.inactive_time = time.time()
 def run_server(self):
     last_time = time.time()
     count = 0
     while run_event.is_set():
         self.serve()
         time_diff = time.time() - last_time
         if time_diff > CONFIG["wait_time"]:
             count += 1
             self.trim_connections()
             logging.debug("send_get_state")
             gvpn.do_get_state(self.sock)
             last_time = time.time()
예제 #4
0
 def run_server(self):
     last_time = time.time()
     count = 0
     while run_event.is_set():
         self.serve()
         time_diff = time.time() - last_time
         if time_diff > CONFIG["wait_time"]:
             count += 1
             self.trim_connections()
             logging.debug("send_get_state")
             gvpn.do_get_state(self.sock)
             last_time = time.time()