Beispiel #1
0
    def make_threads(self):
        program = Program(self)

        path = opsi.__file__
        register_modules(program, path)

        # self.__create_thread__(program.mainloop)
        self.threads.append(
            ShutdownThread(program.mainloop, name="Program thread", autostart=True)
        )

        port = choose_port(self.ports)
        if not port:
            if isinstance(self.ports, tuple):
                msg = f"Unable to bind to any of ports {self.ports}"
            else:
                msg = f"Unable to bind to port {self.ports}"
            LOGGER.critical(msg)
            self.shutdown()
            return

        webserver = WebServer(program, join(path, "frontend"), port)
        self.threads.append(WebserverThread(webserver.app, host="0.0.0.0", port=port))

        if self.persist:
            self.load_persistence(program)
Beispiel #2
0
    def __init__(self, hook):
        self._on = False
        self.hook = hook
        self.pipelines = {}
        self.engine: engine.Engine = None

        ports = [554, 1181]
        self.port = choose_port(ports)
        if not self.port:
            raise ValueError("Unable to bind to any of ports {}".format(ports))