def start(self, application, default_port): """ Run a WSGI server with the given application. :param application: A function that can be called with no arguments that will return the application to run in the WSGI server :param default_port: Port to bind to if none is specified in conf """ def kill_children(*args): """Kills the entire process group.""" self.logger.error(_('SIGTERM or SIGINT received')) signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGINT, signal.SIG_IGN) self.running = False os.killpg(0, signal.SIGTERM) def hup(*args): """ Shuts down the server, but allows running requests to complete """ self.logger.error(_('SIGHUP received')) signal.signal(signal.SIGHUP, signal.SIG_IGN) self.running = False self.app_func = application self.sock = get_socket(default_port) os.umask(027) # ensure files are created with the correct privileges self.logger = os_logging.getLogger('eventlet.wsgi.server') self.exec_init_method() if CONF.workers == 0: # Useful for profiling, test, debug etc. self.pool = self.create_pool() self.pool.spawn_n(self._single_run, self.app_func(), self.sock) self.pool.spawn_n(self.start_looping) return else: self.logger.info(_("Starting %d workers") % CONF.workers) signal.signal(signal.SIGTERM, kill_children) signal.signal(signal.SIGINT, kill_children) signal.signal(signal.SIGHUP, hup) while len(self.children) < CONF.workers: self.run_child() # Note(hzzhoushaoyu): parent process will wait for child, # should not run looping in parent self.run_looping_in_child()
import functools import inspect import os import platform import subprocess import sys import time import uuid from webob import exc from umbrella.common import exception import umbrella.common.log as logging LOG = logging.getLogger(__name__) def get_support_keys(search_opts={}, support_params={}): values = {} for params in support_params: if params in search_opts: values[params] = search_opts[params] return values def mb_to_gb(result): return round((float(result) / 1024), 2) def convert_mem_to_gb_for_monitor(result):
from umbrella.common import exception from umbrella.db.sqlalchemy import migration from umbrella.db.sqlalchemy import models from umbrella.common import cfg import umbrella.common.log as os_logging from umbrella.common import timeutils _ENGINE = None _MAKER = None _MAX_RETRIES = None _RETRY_INTERVAL = None BASE = models.BASE sa_logger = None LOG = os_logging.getLogger(__name__) db_opts = [ cfg.IntOpt('sql_idle_timeout', default=3600), cfg.IntOpt('sql_max_retries', default=10), cfg.IntOpt('sql_retry_interval', default=1), cfg.BoolOpt('db_auto_create', default=False), ] CONF = cfg.CONF CONF.register_opts(db_opts) def ping_listener(dbapi_conn, connection_rec, connection_proxy):