コード例 #1
0
ファイル: ServerController.py プロジェクト: Yoitsu/hydrus
    def SetServices(self, services):

        # doesn't need the dirty_object_lock because the caller takes it

        # first test available ports

        my_ports = {s.GetPort() for s in self._services}

        for service in services:

            port = service.GetPort()

            if port not in my_ports and HydrusNetworking.LocalPortInUse(port):

                raise HydrusExceptions.ServerException(
                    'Something was already bound to port ' + str(port))

        #

        self._services = services

        self.CallToThread(self.services_upnp_manager.SetServices,
                          self._services)

        [self._admin_service] = [
            service for service in self._services
            if service.GetServiceType() == HC.SERVER_ADMIN
        ]

        self.SetRunningTwistedServices(self._services)
コード例 #2
0
ファイル: ServerController.py プロジェクト: Yoitsu/hydrus
    def InitView(self):

        HydrusController.HydrusController.InitView(self)

        port = self._admin_service.GetPort()

        if HydrusNetworking.LocalPortInUse(port):

            HydrusData.Print(
                'Something is already bound to port ' + str(port) +
                ', so your administration service cannot be started. Please quit the server and retry once the port is clear.'
            )

        else:

            self.SetRunningTwistedServices(self._services)

        #

        job = self.CallRepeating(5.0, 600.0, self.SyncRepositories)

        self._daemon_jobs['sync_repositories'] = job

        job = self.CallRepeating(0.0, 30.0, self.SaveDirtyObjects)

        self._daemon_jobs['save_dirty_objects'] = job

        job = self.CallRepeating(0.0, 86400.0, self.DeleteOrphans)

        self._daemon_jobs['delete_orphans'] = job
コード例 #3
0
    def InitView(self):

        HydrusController.HydrusController.InitView(self)

        port = self._admin_service.GetPort()

        if HydrusNetworking.LocalPortInUse(port):

            HydrusData.Print(
                'Something is already bound to port ' + str(port) +
                ', so your administration service cannot be started. Please quit the server and retry once the port is clear.'
            )

        else:

            self.SetRunningTwistedServices(self._services)

        #

        job = self.CallRepeating(5.0, HydrusNetwork.UPDATE_CHECKING_PERIOD,
                                 self.SyncRepositories)
        job.WakeOnPubSub('notify_new_repo_sync')

        self._daemon_jobs['sync_repositories'] = job

        job = self.CallRepeating(0.0, 30.0, self.SaveDirtyObjects)

        self._daemon_jobs['save_dirty_objects'] = job

        job = self.CallRepeating(30.0, 86400.0, self.DoDeferredPhysicalDeletes)
        job.WakeOnPubSub('notify_new_physical_file_deletes')

        self._daemon_jobs['deferred_physical_deletes'] = job

        job = self.CallRepeating(120.0, 3600.0 * 4, self.NullifyHistory)
        job.WakeOnPubSub('notify_new_nullification')

        self._daemon_jobs['nullify_history'] = job
コード例 #4
0
ファイル: ServerController.py プロジェクト: Yoitsu/hydrus
            def StartServices(*args, **kwargs):

                HydrusData.Print('Starting services\u2026')

                for service in services:

                    service_key = service.GetServiceKey()
                    service_type = service.GetServiceType()

                    name = service.GetName()

                    try:

                        port = service.GetPort()

                        if service_type == HC.SERVER_ADMIN:

                            http_factory = ServerServer.HydrusServiceAdmin(
                                service)

                        elif service_type == HC.FILE_REPOSITORY:

                            http_factory = ServerServer.HydrusServiceRepositoryFile(
                                service)

                        elif service_type == HC.TAG_REPOSITORY:

                            http_factory = ServerServer.HydrusServiceRepositoryTag(
                                service)

                        else:

                            return

                        (ssl_cert_path, ssl_key_path) = self.db.GetSSLPaths()

                        sslmethod = twisted.internet.ssl.SSL.TLSv1_2_METHOD

                        context_factory = twisted.internet.ssl.DefaultOpenSSLContextFactory(
                            ssl_key_path, ssl_cert_path, sslmethod)

                        ipv6_port = None

                        try:

                            ipv6_port = reactor.listenSSL(port,
                                                          http_factory,
                                                          context_factory,
                                                          interface='::')

                        except Exception as e:

                            HydrusData.Print('Could not bind to IPv6:')

                            HydrusData.Print(str(e))

                        ipv4_port = None

                        try:

                            ipv4_port = reactor.listenSSL(
                                port, http_factory, context_factory)

                        except:

                            if ipv6_port is None:

                                raise

                        self._service_keys_to_connected_ports[service_key] = (
                            ipv4_port, ipv6_port)

                        if HydrusNetworking.LocalPortInUse(port):

                            HydrusData.Print('Running "{}" on port {}.'.format(
                                name, port))

                        else:

                            raise Exception(
                                'Tried to bind port {} for "{}" but it failed.'
                                .format(port, name))

                    except Exception as e:

                        HydrusData.Print(traceback.format_exc())

                HydrusData.Print('Services started')