def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) uwsgi.log(str(env)) if env['PATH_INFO'] == '/logme': uwsgi.log_this_request() return "log written"
def apply_config_dict(config_dict, prefix=''): for name, value in config_dict.items(): if '_' in name: name = name.replace('_', '-') if not name.startswith(prefix): continue name = name[len(prefix):] if name not in options: uwsgi.log('Invalid block_ server option in uWSGI config file: {}{}'.format(prefix, name)) sys.exit(1) options._options[name].parse(value.decode())
def spawn_on_socket(fd): worker_id = uwsgi.worker_id() application = make_app(debug=options.debug) server = HTTPServer(application, xheaders=True, max_body_size=options.max_body_size) sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) server.add_sockets([sock]) if options.prometheus_port: prometheus_port = options.prometheus_port + worker_id uwsgi.log('starting prometheus server on port %d' % prometheus_port) start_http_server(prometheus_port) uwsgi.log('tornado plumber reporting for duty on uWSGI worker %s' % worker_id)
def process_request(self, request): if not db_loaded: load_db() tz = request.session.get('django_timezone') if not tz: ip = get_client_ip(request) # fetch the timezone from pygeoip if ip != '127.0.0.1': tz = db.time_zone_by_addr(ip) uwsgi.log(u"got timezone: %s, ip: %s" % (tz, ip)) if not tz: timezone.get_default_timezone() if tz: timezone.activate(tz) request.session['django_timezone'] = tz else: timezone.deactivate()
import uwsgi uwsgi.log("I am uWSGI %s" % uwsgi.version) def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) uwsgi.log(str(env)) if env['PATH_INFO'] == '/logme': uwsgi.log_this_request() return "log written"
def application(env, start_response): start_response('200 Ok', [('Content-type', 'text/plain')]) yield "hello" uwsgi.log("this is supposed to be a message to the log srv. read me?")
if not os.path.exists(file): print('logging configuration {} not found, ignoring'.format(file)) return with open(file, 'r') as conf: conf_dictionary = json.load(conf) logging.config.dictConfig(conf_dictionary) tornado.platform.asyncio.AsyncIOMainLoop().install() # Parse configuration from uWSGI config apply_config_dict(uwsgi.opt, prefix='block-') # Parse command line as well (from --pyargv) # Overrides configuration file parse_arguments(sys.argv) configure_logging() signal.signal(signal.SIGINT, stop_ioloop) signal.signal(signal.SIGHUP, stop_ioloop) # spawn a handler for every uWSGI socket for fd in uwsgi.sockets: spawn_on_socket(fd) loop = tornado.ioloop.IOLoop.current() # set_blocking_log_threshold is an unique feature of Tornado's own IO loop, and not available with the asyncio implementations # loop.set_blocking_log_threshold(1) loop.start() uwsgi.log('Worker %s dead.' % uwsgi.worker_id())
def log(): uwsgi.log(request.form['message']) flash("log message written") return redirect(url_for('index'))
# Loading modules from path _view_classes.extend(load_modules(_modules_list)) # Loading from installed packages _view_classes.extend(load_packages(_package_list)) _protocols_enabled = [] for _view_class in _view_classes: _instance = _view_class() _instance.set_flask(app) _protocols_enabled.extend(_instance.protocols) uwsgi.log('\n') envoxy.log.system('[{}] Loaded "{}".\n'.format( envoxy.log.style.apply('###', envoxy.log.style.BLUE_FG), str(_view_class))) _default_zmq_backend = _conf_content.get('default_zmq_backend') if _default_zmq_backend and _default_zmq_backend.get('enabled'): _path_prefix = _default_zmq_backend.get('path_prefix', '/') try: _server_key = _default_zmq_backend.get( 'server_key', next(iter(zmqc.instance()._instances.keys())))