Exemplo n.º 1
0
    def onConnect(self):
        """
        Called when the worker has connected to the node's management router.
        """
        self._node_id = self.config.extra.node
        self._worker_id = self.config.extra.worker
        self._uri_prefix = u'crossbar.worker.{}'.format(self._worker_id)

        NativeProcess.onConnect(self, False)

        self._module_tracker = TrackingModuleReloader(snapshot=False)

        self._profiles = {}

        # flag indicating when worker is shutting down
        self._is_shutting_down = False

        # Jinja2 templates for Web (like WS status page et al)
        #
        template_dirs = []
        for package, directory in self.personality.TEMPLATE_DIRS:
            dir_path = os.path.abspath(
                pkg_resources.resource_filename(package, directory))
            template_dirs.append(dir_path)
        self.log.debug("Using Web templates from {template_dirs}",
                       template_dirs=template_dirs)
        self._templates = jinja2.Environment(
            loader=jinja2.FileSystemLoader(template_dirs), autoescape=True)

        self.join(self.config.realm)
Exemplo n.º 2
0
    def onConnect(self):
        """
        Called when the worker has connected to the node's management router.
        """
        self._node_id = self.config.extra.node
        self._uri_prefix = 'crossbar.node.{}.worker.{}'.format(
            self.config.extra.node, self.config.extra.worker)

        NativeProcessSession.onConnect(self, False)

        self._module_tracker = TrackingModuleReloader()

        self._profiles = {}

        # flag indicating when worker is shutting down
        self._is_shutting_down = False

        # Jinja2 templates for Web (like WS status page et al)
        #
        templates_dir = os.path.abspath(
            pkg_resources.resource_filename("crossbar", "web/templates"))
        self.log.debug("Using Web templates from {templates_dir}",
                       templates_dir=templates_dir)
        self._templates = jinja2.Environment(
            loader=jinja2.FileSystemLoader(templates_dir))

        self.join(self.config.realm)
Exemplo n.º 3
0
    def onConnect(self):
        """
        Called when the worker has connected to the node's management router.
        """
        self._uri_prefix = 'crossbar.node.{}.worker.{}'.format(self.config.extra.node, self.config.extra.worker)

        NativeProcessSession.onConnect(self, False)

        self._module_tracker = TrackingModuleReloader(debug=True)

        self.join(self.config.realm)
Exemplo n.º 4
0
    def onConnect(self):
        """
        Called when the worker has connected to the node's management router.
        """
        NativeProcess.onConnect(self, False)

        self._module_tracker = TrackingModuleReloader(snapshot=False)

        self._profiles = {}

        # flag indicating when worker is shutting down
        self._is_shutting_down = False

        # Jinja2 templates for Web (like WS status page et al)
        #
        self._templates_dir = []
        for package, directory in self.personality.TEMPLATE_DIRS:
            dir_path = os.path.abspath(
                pkg_resources.resource_filename(package, directory))
            self._templates_dir.append(dir_path)
        self.log.debug("Using Web templates from {template_dirs}",
                       template_dirs=self._templates_dir)

        # FIXME: make configurable, but default should remain SandboxedEnvironment for security
        if True:
            # The sandboxed environment. It works like the regular environment but tells the compiler to
            # generate sandboxed code.
            # https://jinja.palletsprojects.com/en/2.11.x/sandbox/#jinja2.sandbox.SandboxedEnvironment
            self._templates = SandboxedEnvironment(
                loader=jinja2.FileSystemLoader(self._templates_dir),
                autoescape=True)
        else:
            self._templates = Environment(loader=jinja2.FileSystemLoader(
                self._templates_dir),
                                          autoescape=True)

        self.join(self.config.realm)