def paste_server(app, gcfg=None, host="127.0.0.1", port=None, *args, **kwargs): """\ A paster server. Then entry point in your paster ini file should looks like this: [server:main] use = egg:gunicorn#main host = 127.0.0.1 port = 5000 """ util.warn("""This command is deprecated. You should now use the `--paste` option. Ex.: gunicorn --paste development.ini """) from gunicorn.app.pasterapp import PasterServerApplication PasterServerApplication(app, gcfg=gcfg, host=host, port=port, *args, **kwargs).run()
def setup(self, cfg): self.loglevel = self.LOG_LEVELS.get(cfg.loglevel.lower(), logging.INFO) self.error_log.setLevel(self.loglevel) self.access_log.setLevel(logging.INFO) # set gunicorn.error handler if self.cfg.capture_output and cfg.errorlog != "-": for stream in sys.stdout, sys.stderr: stream.flush() self.logfile = open(cfg.errorlog, 'a+') os.dup2(self.logfile.fileno(), sys.stdout.fileno()) os.dup2(self.logfile.fileno(), sys.stderr.fileno()) self._set_handler(self.error_log, cfg.errorlog, logging.Formatter(self.error_fmt, self.datefmt)) # set gunicorn.access handler if cfg.accesslog is not None: self._set_handler(self.access_log, cfg.accesslog, fmt=logging.Formatter(self.access_fmt), stream=sys.stdout) # set syslog handler if cfg.syslog: self._set_syslog_handler( self.error_log, cfg, self.syslog_fmt, "error" ) if not cfg.disable_redirect_access_to_syslog: self._set_syslog_handler( self.access_log, cfg, self.syslog_fmt, "access" ) if dictConfig is None and cfg.logconfig_dict: util.warn("Dictionary-based log configuration requires " "Python 2.7 or above.") if dictConfig and cfg.logconfig_dict: config = CONFIG_DEFAULTS.copy() config.update(cfg.logconfig_dict) try: dictConfig(config) except ( AttributeError, ImportError, ValueError, TypeError ) as exc: raise RuntimeError(str(exc)) elif cfg.logconfig: if os.path.exists(cfg.logconfig): defaults = CONFIG_DEFAULTS.copy() defaults['__file__'] = cfg.logconfig defaults['here'] = os.path.dirname(cfg.logconfig) fileConfig(cfg.logconfig, defaults=defaults, disable_existing_loggers=False) else: msg = "Error: log config '%s' not found" raise RuntimeError(msg % cfg.logconfig)
def run(): """\ The ``gunicorn_paster`` command for launcing Paster compatible apllications like Pylons or Turbogears2 """ util.warn("""This command is deprecated. You should now use the `--paste` option. Ex.: gunicorn --paste development.ini """) from gunicorn.app.pasterapp import PasterApplication PasterApplication("%(prog)s [OPTIONS] pasteconfig.ini").run()
def run(): """\ The ``gunicorn_paster`` command for launching Paster compatible applications like Pylons or Turbogears2 """ util.warn("""This command is deprecated. You should now use the `--paste` option. Ex.: gunicorn --paste development.ini """) from gunicorn.app.pasterapp import PasterApplication PasterApplication("%(prog)s [OPTIONS] pasteconfig.ini").run()
def run(): """\ The ``gunicorn_django`` command line runner for launching Django applications. """ util.warn("""This command is deprecated. You should now run your application with the WSGI interface installed with your project. Ex.: gunicorn myproject.wsgi:application See https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/gunicorn/ for more info.""") from gunicorn.app.djangoapp import DjangoApplication DjangoApplication("%(prog)s [OPTIONS] [SETTINGS_PATH]").run()
def run(): """\ The ``gunicorn_django`` command line runner for launching Django applications. """ util.warn("""This command is deprecated. You should now run your application with the WSGI interface installed with your project. Ex.: gunicorn myproject.wsgi:application See https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/gunicorn/ for more info.""") from gunicorn.app.djangoapp import DjangoApplication DjangoApplication("%(prog)s [OPTIONS] [SETTINGS_PATH]").run()
def handle(self, addrport=None, *args, **options): # deprecation warning to announce future deletion in R21 util.warn("""This command is deprecated. You should now run your application with the WSGI interface installed with your project. Ex.: gunicorn myproject.wsgi:application See https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/gunicorn/ for more info.""") if args: raise CommandError('Usage is run_gunicorn %s' % self.args) if addrport: options['bind'] = addrport admin_media_path = options.pop('admin_media_path', '') DjangoApplicationCommand(options, admin_media_path).run()
def handle(self, addrport=None, *args, **options): # deprecation warning to announce future deletion in R21 util.warn("""This command is deprecated. You should now run your application with the WSGI interface installed with your project. Ex.: gunicorn myproject.wsgi:application See https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/gunicorn/ for more info.""") if args: raise CommandError('Usage is run_gunicorn %s' % self.args) if addrport: sys.argv = sys.argv[:-1] options['bind'] = addrport admin_media_path = options.pop('admin_media_path', '') DjangoApplicationCommand(options, admin_media_path).run()
def test_warn(capsys): util.warn('test warn') _, err = capsys.readouterr() assert '!!! WARNING: test warn' in err
# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. import sys from gunicorn import util if sys.version_info >= (3, 4): try: import aiohttp # pylint: disable=unused-import except ImportError: raise RuntimeError("You need aiohttp installed to use this worker.") else: try: from aiohttp.worker import GunicornWebWorker as AiohttpWorker except ImportError: from gunicorn.workers._gaiohttp import AiohttpWorker util.warn( "The 'gaiohttp' worker is deprecated. See --worker-class " "documentation for more information." ) __all__ = ['AiohttpWorker'] else: raise RuntimeError("You need Python >= 3.4 to use the gaiohttp worker")