예제 #1
0
    def on_start(self):
        WorkController.on_start(self)

        # this signal can be used to e.g. change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname,
            instance=self,
            conf=self.app.conf,
        )

        if getattr(os, 'getuid', None) and os.getuid() == 0:
            warnings.warn(
                RuntimeWarning(
                    'Running the worker with superuser privileges is discouraged!',
                ))

        if self.purge:
            self.purge_messages()

        # Dump configuration to screen so we have some basic information
        # for when users sends bug reports.
        sys.__stdout__.write(
            str(self.colored.cyan(' \n', self.startup_info())) +
            str(self.colored.reset(self.extra_info() or '')) + '\n')
        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
예제 #2
0
    def on_start(self):
        if not self._custom_logging and self.redirect_stdouts:
            self.app.log.redirect_stdouts(self.redirect_stdouts_level)

        WorkController.on_start(self)

        # this signal can be used to e.g. change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=self.app.conf,
        )

        if getattr(os, 'getuid', None) and os.getuid() == 0:
            warnings.warn(RuntimeWarning(
                'Running the worker with superuser privileges is discouraged!',
            ))

        if self.purge:
            self.purge_messages()

        # Dump configuration to screen so we have some basic information
        # for when users sends bug reports.
        sys.__stdout__.write(
            str(self.colored.cyan(' \n', self.startup_info())) +
            str(self.colored.reset(self.extra_info() or '')) + '\n'
        )
        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
예제 #3
0
    def on_start(self):
        app = self.app
        WorkController.on_start(self)

        # this signal can be used to e.g. change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=app.conf,
        )

        if self.purge:
            self.purge_messages()

        # Dump configuration to screen so we have some basic information
        # for when users sends bug reports.
        use_image = self._term_supports_images()
        if use_image:
            self.termimage(static.logo_as_base64())
        print(safe_str(''.join([
            string(self.colored.cyan(
                ' \n', self.startup_info(artlines=not use_image))),
            string(self.colored.reset(self.extra_info() or '')),
        ])), file=sys.__stdout__)
        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
        if not self._custom_logging and self.redirect_stdouts:
            app.log.redirect_stdouts(self.redirect_stdouts_level)
예제 #4
0
파일: worker.py 프로젝트: pimiento/celery
    def on_start(self):
        if not self._custom_logging and self.redirect_stdouts:
            self.app.log.redirect_stdouts(self.redirect_stdouts_level)

        WorkController.on_start(self)

        # this signal can be used to e.g. change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=self.app.conf,
        )

        if getattr(os, 'getuid', None) and os.getuid() == 0:
            accept_encoding = self.app.conf.CELERY_ACCEPT_CONTENT
            if ('pickle' in accept_encoding or
                    'application/x-python-serialize' in accept_encoding):
                if not C_FORCE_ROOT:
                    raise RuntimeError(ROOT_DISALLOWED)
            warnings.warn(RuntimeWarning(ROOT_DISCOURAGED))

        if self.purge:
            self.purge_messages()

        # Dump configuration to screen so we have some basic information
        # for when users sends bug reports.
        sys.__stdout__.write(
            str(self.colored.cyan(' \n', self.startup_info())) +
            str(self.colored.reset(self.extra_info() or '')) + '\n'
        )
        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
예제 #5
0
파일: worker.py 프로젝트: wonderb0lt/celery
    def on_start(self):
        if not self._custom_logging and self.redirect_stdouts:
            self.app.log.redirect_stdouts(self.redirect_stdouts_level)

        WorkController.on_start(self)

        # this signal can be used to e.g. change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname,
            instance=self,
            conf=self.app.conf,
        )

        if not self.app.conf.value_set_for('CELERY_ACCEPT_CONTENT'):
            warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))

        if self.purge:
            self.purge_messages()

        # Dump configuration to screen so we have some basic information
        # for when users sends bug reports.
        print(safe_str(''.join([
            string(self.colored.cyan(' \n', self.startup_info())),
            string(self.colored.reset(self.extra_info() or '')),
        ])),
              file=sys.__stdout__)
        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
예제 #6
0
파일: worker.py 프로젝트: quoter/celery
    def on_start(self):
        WorkController.on_start(self)

        # apply task execution optimizations
        trace.setup_worker_optimizations(self.app)

        # this signal can be used to e.g. change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=self.app.conf,
        )

        if getattr(os, 'getuid', None) and os.getuid() == 0:
            warnings.warn(RuntimeWarning(
                'Running celeryd with superuser privileges is discouraged!'))

        if self.purge:
            self.purge_messages()

        # Dump configuration to screen so we have some basic information
        # for when users sends bug reports.
        print(str(self.colored.cyan(' \n', self.startup_info())) +
              str(self.colored.reset(self.extra_info() or '')))
        self.set_process_status('-active-')
        self.setup_logging()
        self.install_platform_tweaks(self)
예제 #7
0
파일: worker.py 프로젝트: xpxu/celery
    def on_start(self):
        app = self.app
        WorkController.on_start(self)

        # this signal can be used to, for example, change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=app.conf,
        )

        if self.purge:
            self.purge_messages()

        # Dump configuration to screen so we have some basic information
        # for when users sends bug reports.
        use_image = term.supports_images()
        if use_image:
            print(term.imgcat(static.logo()))
        print(safe_str(''.join([
            string(self.colored.cyan(
                ' \n', self.startup_info(artlines=not use_image))),
            string(self.colored.reset(self.extra_info() or '')),
        ])), file=sys.__stdout__)
        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
        if not self._custom_logging and self.redirect_stdouts:
            app.log.redirect_stdouts(self.redirect_stdouts_level)
예제 #8
0
파일: worker.py 프로젝트: huyidao625/celery
    def on_start(self):
        if not self._custom_logging and self.redirect_stdouts:
            self.app.log.redirect_stdouts(self.redirect_stdouts_level)

        WorkController.on_start(self)

        # this signal can be used to e.g. change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(sender=self.hostname, instance=self, conf=self.app.conf)

        if not self.app.conf.value_set_for("accept_content"):
            warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))

        if self.purge:
            self.purge_messages()

        # Dump configuration to screen so we have some basic information
        # for when users sends bug reports.
        print(
            safe_str(
                "".join(
                    [
                        string(self.colored.cyan(" \n", self.startup_info())),
                        string(self.colored.reset(self.extra_info() or "")),
                    ]
                )
            ),
            file=sys.__stdout__,
        )
        self.set_process_status("-active-")
        self.install_platform_tweaks(self)
예제 #9
0
    def on_start(self):
        if not self._custom_logging and self.redirect_stdouts:
            self.app.log.redirect_stdouts(self.redirect_stdouts_level)

        WorkController.on_start(self)

        # this signal can be used to e.g. change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=self.app.conf,
        )

        if getattr(os, 'getuid', None) and os.getuid() == 0:
            accept_encoding = self.app.conf.CELERY_ACCEPT_CONTENT
            if ('pickle' in accept_encoding or
                    'application/x-python-serialize' in accept_encoding):
                if not C_FORCE_ROOT:
                    raise RuntimeError(ROOT_DISALLOWED)
            warnings.warn(RuntimeWarning(ROOT_DISCOURAGED))

        if not self.app.conf.value_set_for('CELERY_ACCEPT_CONTENT'):
            warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))

        if self.purge:
            self.purge_messages()

        # Dump configuration to screen so we have some basic information
        # for when users sends bug reports.
        sys.__stdout__.write(
            str(self.colored.cyan(' \n', self.startup_info())) +
            str(self.colored.reset(self.extra_info() or '')) + '\n'
        )
        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
예제 #10
0
    def on_start(self):
        app = self.app
        WorkController.on_start(self)

        # this signal can be used to, for example, change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=app.conf,
        )

        if self.purge:
            self.purge_messages()

        if not self.quiet:
            self.emit_banner()

        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
        if not self._custom_logging and self.redirect_stdouts:
            app.log.redirect_stdouts(self.redirect_stdouts_level)

        # TODO: Remove the following code in Celery 6.0
        if app.conf.maybe_warn_deprecated_settings():
            logger.warning(
                "Please run `celery upgrade settings path/to/settings.py` "
                "to avoid these warnings and to allow a smoother upgrade "
                "to Celery 6.0."
            )
예제 #11
0
    def on_start(self):
        app = self.app
        WorkController.on_start(self)

        # this signal can be used to, for example, change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname,
            instance=self,
            conf=app.conf,
        )

        if self.purge:
            self.purge_messages()

        if not self.quiet:
            self.emit_banner()

        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
        if not self._custom_logging and self.redirect_stdouts:
            app.log.redirect_stdouts(self.redirect_stdouts_level)

        # TODO: Remove the following code in Celery 6.0
        # This qualifies as a hack for issue #6366.
        # a hack via app.__reduce_keys__(), but that may not work properly in
        # all cases
        warn_deprecated = True
        config_source = app._config_source
        if isinstance(config_source, str):
            # Don't raise the warning when the settings originate from
            # django.conf:settings
            warn_deprecated = config_source.lower() not in [
                'django.conf:settings',
            ]

        if warn_deprecated:
            if app.conf.maybe_warn_deprecated_settings():
                logger.warning(
                    "Please run `celery upgrade settings path/to/settings.py` "
                    "to avoid these warnings and to allow a smoother upgrade "
                    "to Celery 6.0.")
예제 #12
0
    def on_start(self):
        app = self.app
        WorkController.on_start(self)

        # this signal can be used to, for example, change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=app.conf,
        )

        if self.purge:
            self.purge_messages()

        if not self.quiet:
            self.emit_banner()

        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
        if not self._custom_logging and self.redirect_stdouts:
            app.log.redirect_stdouts(self.redirect_stdouts_level)
예제 #13
0
파일: worker.py 프로젝트: jwasserzug/celery
    def on_start(self):
        app = self.app
        WorkController.on_start(self)

        # this signal can be used to, for example, change queues after
        # the -Q option has been applied.
        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=app.conf,
        )

        if self.purge:
            self.purge_messages()

        if not self.quiet:
            self.emit_banner()

        self.set_process_status('-active-')
        self.install_platform_tweaks(self)
        if not self._custom_logging and self.redirect_stdouts:
            app.log.redirect_stdouts(self.redirect_stdouts_level)