How to use the uwsgi.opt function in uWSGI

To help you get started, we’ve selected a few uWSGI examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github baude / image-scanner / image_scanner / rest.py View on Github external
def get_env_info():
    #conf_file = "/etc/image-scanner/image-scanner.conf"
    #config = ConfigParser.RawConfigParser()
    #try:
    #    # Check if we have a conf file
    #    config.read(conf_file)
    #    # If we find a conf-file, override it if passed via command line
    #    # else use the conf-file
    #    print uwsgi.opt.get('socket')
    #    port = config.get('main', 'port')
    #    host = config.get('main', 'hostip')
    #    dockerhost = config.get('main', 'dockerhost')
    #except ConfigParser.NoSectionError:
    #    # No conf file found
    #    raise
    host, port = uwsgi.opt.get('socket').split(':')
    dockerhost = uwsgi.opt.get('dockerhost')

    return port, host, dockerhost
github warelab / gramene-curation / gene_curation_project_home / base / gene_curation_project / __init__.py View on Github external
server_config_file = _app_setup_utils.getConfigFile("your_host.cfg")
		else:
			server_config_file = _app_setup_utils.getConfigFile("default.cfg") # default
		
	else:
		if conf["usingUWSGI"]:
			try:
				import uwsgi
				# The uWSGI configuration file defines a key value pair to point
				# to a particular configuration file in this module under "configuration_files".
				# The key is 'flask_config_file', and the value is the name of the configuration
				# file.
				# NOTE: For Python 3, the value from the uwsgi.opt dict below must be decoded, e.g.
				# config_file = uwsgi.opt['flask-config-file'].decode("utf-8")
				if 'flask-config-file' in uwsgi.opt:
					config_file = uwsgi.opt['flask-config-file'].decode("utf-8")
				else:
					config_file = 'default.cfg'
				server_config_file = _app_setup_utils.getConfigFile(config_file)
			except ImportError:
				print("Trying to run in production mode, but not running under uWSGI.\n"
					  "You might try running again with the '--debug' (or '-d') flag.")
				sys.exit(1)
	
	if server_config_file:
		print(green_text("Loading config file: "), yellow_text(server_config_file))
		app.config.from_pyfile(server_config_file)
	
	# -----------------------------
	# Perform app setup below here.
	# -----------------------------
github agdsn / sipa / sipa.py View on Github external
parser.add_argument("-p", "--port", action="store",
                        help="tcp port to use", type=int, default=5000)
    args = parser.parse_args()

    def preparation(app):
        if args.debug:
            app.debug = True
            logger.warning('Running in Debug mode')

    app = create_app(prepare_callable=preparation)
    app.run(debug=args.debug, host=args.host, port=args.port)

else:
    # __name__ == 'uwsgi_file_sipa'
    import uwsgi
    debug = uwsgi.opt.get('debug', False)
    app = create_app()
    if debug:
        logger.warning("Running in debug mode")
        app.debug = True
        from werkzeug.debug import DebuggedApplication
        app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)
    # app will now be used by `uwsgi`

@app.context_processor
def inject_hotline_status():
    return dict(support_hotline_available=support_hotline_available())
github unbit / uwsgi / examples / welcome3.py View on Github external
def serve_config(e, sr):
    sr('200 OK', [('Content-Type', 'text/html')])
    for opt in uwsgi.opt.keys():
        body = "{opt} = {optvalue}<br>".format(opt=opt, optvalue=uwsgi.opt[opt].decode('ascii'))
        yield bytes(body.encode('ascii'))
github agdsn / sipa / sipa / initialization.py View on Github external
def update_uwsgi(signum):
            flatpages_root = app.config["FLATPAGES_ROOT"]
            logger.debug("Updating git repository at %s", flatpages_root)
            hasToReload = update_repo(flatpages_root)
            if hasToReload:
                logger.debug("Reloading flatpages and uwsgi", extra={'data': {
                    'uwsgi.numproc': uwsgi.numproc,
                    'uwsgi.opt': uwsgi.opt,
                    'uwsgi.applications': uwsgi.applications,
                }})
                uwsgi.reload()
github quodlibet / quodlibet / quodlibet / quodlibet / packages / raven / utils / compat.py View on Github external
def check_threads():
    try:
        from uwsgi import opt
    except ImportError:
        return

    # When `threads` is passed in as a uwsgi option,
    # `enable-threads` is implied on.
    if 'threads' in opt:
        return

    if str(opt.get('enable-threads', '0')).lower() in ('false', 'off', 'no', '0'):
        from warnings import warn
        warn(Warning('We detected the use of uwsgi with disabled threads.  '
                     'This will cause issues with the transport you are '
github unbit / uwsgi / examples / welcome.py View on Github external
def serve_config(e, sr):
    sr('200 OK', [('Content-Type', 'text/html')])
    for opt in uwsgi.opt.keys():
        yield "<b>%s</b> = %s<br>" % (opt, uwsgi.opt[opt])
github getsentry / sentry-python / sentry_sdk / _compat.py View on Github external
def check_thread_support():
    # type: () -> None
    try:
        from uwsgi import opt  # type: ignore
    except ImportError:
        return

    # When `threads` is passed in as a uwsgi option,
    # `enable-threads` is implied on.
    if "threads" in opt:
        return

    if str(opt.get("enable-threads", "0")).lower() in ("false", "off", "no", "0"):
        from warnings import warn

        warn(
            Warning(
                "We detected the use of uwsgi with disabled threads.  "
                "This will cause issues with the transport you are "
github sh4nks / flask-caching / flask_caching / backends / uwsgicache.py View on Github external
if platform.python_implementation() == "PyPy":
            raise RuntimeError(
                "uWSGI caching does not work under PyPy, see "
                "the docs for more details."
            )

        try:
            import uwsgi
            self._uwsgi = uwsgi
        except ImportError:
            raise RuntimeError(
                "uWSGI could not be imported, are you running under uWSGI?"
            )

        if 'cache2' not in uwsgi.opt:
            raise RuntimeError(
                "You must enable cache2 in uWSGI configuration: "
                "https://uwsgi-docs.readthedocs.io/en/latest/Caching.html")

        self.cache = cache
github getsentry / sentry-python / sentry_sdk / _compat.py View on Github external
def check_thread_support():
    # type: () -> None
    try:
        from uwsgi import opt  # type: ignore
    except ImportError:
        return

    # When `threads` is passed in as a uwsgi option,
    # `enable-threads` is implied on.
    if "threads" in opt:
        return

    if str(opt.get("enable-threads", "0")).lower() in ("false", "off", "no", "0"):
        from warnings import warn

        warn(
            Warning(
                "We detected the use of uwsgi with disabled threads.  "
                "This will cause issues with the transport you are "