Exposes a CLI to configure the SharQ Server and runs the server.
544156
def run():
    """"""
    # create a arg parser and configure it.
    parser = argparse.ArgumentParser(description='SharQ Server.')
    parser.add_argument('-c', '--config', action='store', required=True,
                        help='Absolute path of the SharQ configuration file.',
                        dest='sharq_config')
    parser.add_argument('-gc', '--gunicorn-config', action='store', required=False,
                        help='Gunicorn configuration file.',
                        dest='gunicorn_config')
    parser.add_argument('--version', action='version', version='SharQ Server %s' % __version__)
    args = parser.parse_args()

    # read the configuration file and set gunicorn options.
    config_parser = ConfigParser.SafeConfigParser()
    # get the full path of the config file.
    sharq_config  = os.path.abspath(args.sharq_config)
    config_parser.read(sharq_config)

    host = config_parser.get('sharq-server', 'host')
    port = config_parser.get('sharq-server', 'port')
    bind = '%s:%s' % (host, port)
    try:
        workers = config_parser.get('sharq-server', 'workers')
    except ConfigParser.NoOptionError:
        workers = number_of_workers()

    try:
        accesslog = config_parser.get('sharq-server', 'accesslog')
    except ConfigParser.NoOptionError:
        accesslog = None

    options = {
        'bind': bind,
        'workers': workers,
        'worker_class': 'gevent'  # required for sharq to function.
    }
    if accesslog:
        options.update({
            'accesslog': accesslog
        })

    if args.gunicorn_config:
        gunicorn_config = os.path.abspath(args.gunicorn_config)
        options.update({
            'config': gunicorn_config
        })

    print """
      ___ _              ___    ___
     / __| |_  __ _ _ _ / _ \  / __| ___ _ ___ _____ _ _
     \__ \ ' \/ _` | '_| (_) | \__ \/ -_) '_\ V / -_) '_|
     |___/_||_\__,_|_|  \__\_\ |___/\___|_|  \_/\___|_|

    Version: %s

    Listening on: %s
    """ % (__version__, bind)
    server = setup_server(sharq_config)
    SharQServerApplicationRunner(server.app, options).run()
993693
def run(self):
        
        print("Development server started on http://%s:%s. \n\nPress Ctrl+C to stop\n" % (
            self.manager.args.addr,
            self.manager.args.port)
              )
        if self.manager.args.server_type == 'falcon':
            self.run_with_falcon()
        elif self.manager.args.server_type == 'tornado':
            self.run_with_tornado()
151931
def runserver(hostname, port, no_reloader, debugger, no_evalex, threaded, processes):
    """"""
    app = make_app()
    reloader = not no_reloader
    evalex = not no_evalex
    run_simple(
        hostname,
        port,
        app,
        use_reloader=reloader,
        use_debugger=debugger,
        use_evalex=evalex,
        threaded=threaded,
        processes=processes,
    )
310369
def runserver(**config_kwargs):
    
    # force a full reload in sub processes so they load an updated version of code, this must be called only once
    set_start_method('spawn')

    config = Config(**config_kwargs)
    config.import_app_factory()
    loop = asyncio.get_event_loop()

    loop.run_until_complete(check_port_open(config.main_port, loop))

    aux_app = create_auxiliary_app(
        static_path=config.static_path_str,
        static_url=config.static_url,
        livereload=config.livereload,
    )

    main_manager = AppTask(config, loop)
    aux_app.on_startup.append(main_manager.start)
    aux_app.on_shutdown.append(main_manager.close)

    if config.static_path:
        static_manager = LiveReloadTask(config.static_path, loop)
        logger.debug('starting livereload to watch %s', config.static_path_str)
        aux_app.on_startup.append(static_manager.start)
        aux_app.on_shutdown.append(static_manager.close)

    url = 'http://{0.host}:{0.aux_port}'.format(config)
    logger.info('Starting aux server at %s ◆', url)

    if config.static_path:
        rel_path = config.static_path.relative_to(os.getcwd())
        logger.info('serving static files from ./%s/ at %s%s', rel_path, url, config.static_url)

    return aux_app, config.aux_port, loop, AuxAccessLogger
558040
def run(argv = ARGV)
      # => Parse CLI Configuration
      cli = Options.new
      cli.parse_options(argv)

      # => Grab the Default Values
      default = Config.options

      # => Parse JSON Config File (If Specified and Exists)
      json_config = Util.parse_json_config(cli.config[:config_file] || Config.config_file)

      # => Merge Configuration (CLI Wins)
      config = [default, json_config, cli.config].compact.reduce(:merge)

      # => Apply Configuration
      Config.setup do |cfg|
        cfg.config_file         = config[:config_file]
        cfg.cache_timeout       = config[:cache_timeout].to_i
        cfg.bind                = config[:bind]
        cfg.port                = config[:port]
        cfg.auth_file           = config[:auth_file]
        cfg.state_file          = config[:state_file]
        cfg.environment         = config[:environment].to_sym.downcase
        cfg.chef_api_endpoint   = config[:chef_api_endpoint]
        cfg.chef_api_client     = config[:chef_api_client]
        cfg.chef_api_client_key = config[:chef_api_client_key]
        cfg.chef_api_admin      = config[:chef_api_admin]
        cfg.chef_api_admin_key  = config[:chef_api_admin_key]
        cfg.rd_node_username    = config[:rd_node_username]
      end

      # => Launch the API
      API.run!
    end
648433
def run(cls):
        
        if not all(v is None for v in cls._services.values()):
            cls._set_host_id()
            cls._setup_logging()
            cls._set_process_name()
            cls._set_signal_handlers()
            cls._start_server()
        else:
            cls._logger.error('No services to host')
978008
def main():
    
    parse = argparse.ArgumentParser(description=main.__doc__)
    parse.add_argument("-c", "--command", help="Run this command and exit")
    region = os.environ.get("AWS_REGION", "us-west-1")
    parse.add_argument(
        "-r",
        "--region",
        default=region,
        help="AWS region to connect to (default %(default)s)",
    )
    parse.add_argument(
        "-H",
        "--host",
        default=None,
        help="Host to connect to if using a local instance " "(default %(default)s)",
    )
    parse.add_argument(
        "-p",
        "--port",
        default=8000,
        type=int,
        help="Port to connect to " "(default %(default)d)",
    )
    parse.add_argument(
        "--version", action="store_true", help="Print the version and exit"
    )
    args = parse.parse_args()

    if args.version:
        print(__version__)
        return

    logging.config.dictConfig(LOG_CONFIG)
    cli = DQLClient()
    cli.initialize(region=args.region, host=args.host, port=args.port)

    if args.command:
        command = args.command.strip()
        try:
            cli.run_command(command)
            if cli.engine.partial:
                cli.run_command(";")
        except KeyboardInterrupt:
            pass
    else:
        cli.start()
1361457
def run(args = {})
      @at_stop = []

      extra_options = parse_cli_options!(args)

      # Boot app first, 'cause it might change
      # configuration, loggin settings, etc.
      boot_app!

      parse_gem_options!(extra_options)

      configure_server!

      logger.info "Starting AnyCable gRPC server (pid: #{Process.pid})"

      print_versions!

      logger.info "Serving #{defined?(::Rails) ? 'Rails ' : ''}application from #{boot_file}"

      verify_connection_factory!

      log_grpc! if config.log_grpc

      log_errors!

      @server = AnyCable::Server.new(
        host: config.rpc_host,
        **config.to_grpc_params,
        interceptors: AnyCable.middleware.to_a
      )

      # Make sure middlewares are not adding after server has started
      AnyCable.middleware.freeze

      start_health_server! if config.http_health_port_provided?
      start_pubsub!

      server.start

      run_custom_server_command! unless server_command.nil?

      begin
        wait_till_terminated
      rescue Interrupt => e
        logger.info "Stopping... #{e.message}"

        shutdown

        logger.info "Stopped. Good-bye!"
        exit(0)
      end
    end
204868
def main(args=None):
    
    # parse args
    if args is None:
        args = parse_args(sys.argv[1:])

    # dump example config if that action
    if args.action == 'example-config':
        conf, doc = Config.example_config()
        print(conf)
        sys.stderr.write(doc + "\n")
        return

    # set logging level
    if args.verbose > 1:
        set_log_debug()
    elif args.verbose == 1:
        set_log_info()

    # get our config
    config = Config(args.config)

    if args.action == 'logs':
        aws = AWSInfo(config)
        aws.show_cloudwatch_logs(count=args.log_count)
        return

    if args.action == 'apilogs':
        api_id = get_api_id(config, args)
        aws = AWSInfo(config)
        aws.show_cloudwatch_logs(
            count=args.log_count,
            grp_name='API-Gateway-Execution-Logs_%s/%s' % (
                api_id, config.stage_name
            )
        )
        return

    if args.action == 'queuepeek':
        aws = AWSInfo(config)
        aws.show_queue(name=args.queue_name, delete=args.queue_delete,
                       count=args.msg_count)
        return

    if args.action == 'test':
        run_test(config, args)
        return

    if args.action in ['apply', 'genapply', 'plan', 'destroy']:
        runner = TerraformRunner(config, args.tf_path)
        tf_ver = runner.tf_version
    else:
        tf_ver = tuple(
            [int(x) for x in args.tf_ver.split('.')]
        )

    # if generate or genapply, generate the configs
    if args.action == 'generate' or args.action == 'genapply':
        func_gen = LambdaFuncGenerator(config)
        func_src = func_gen.generate()
        # @TODO: also write func_source to disk
        tf_gen = TerraformGenerator(config, tf_ver=tf_ver)
        tf_gen.generate(func_src)

    # if only generate, exit now
    if args.action == 'generate':
        return

    # run the terraform action
    if args.action == 'apply' or args.action == 'genapply':
        runner.apply(args.stream_tf)
        # conditionally set API Gateway Method settings
        if config.get('api_gateway_method_settings') is not None:
            aws = AWSInfo(config)
            aws.set_method_settings()
    elif args.action == 'plan':
        runner.plan(args.stream_tf)
    else:  # destroy
        runner.destroy(args.stream_tf)
129057
def run(self):
    """"""
    compiler = new_compiler(compiler=self.compiler)
    if compiler.compiler_type == "msvc":
      self.define = [
          ("UNICODE", ""),
      ]

    else:
      command = "sh configure --disable-shared-libs"
      output = self._RunCommand(command)

      print_line = False
      for line in output.split("\n"):
        line = line.rstrip()
        if line == "configure:":
          print_line = True

        if print_line:
          print(line)

      self.define = [
          ("HAVE_CONFIG_H", ""),
          ("LOCALEDIR", "\"/usr/share/locale\""),
      ]

    build_ext.run(self)
369652
def cli_run():
    """"""
    options = CLI.parse_args()
    run(options.CONFIGURATION, options.log_level, options.log_target, options.log_journal)
274452
def runserver(ctx, conf, port, foreground):
    """"""
    config = read_config(conf)

    debug = config['conf'].get('debug', False)
    click.echo('Debug mode {0}.'.format('on' if debug else 'off'))

    port = port or config['conf']['server']['port']

    app_settings = {
        'debug': debug,
        'auto_reload': config['conf']['server'].get('auto_reload', False),
    }
    handlers_settings = __create_handler_settings(config)

    if foreground:
        click.echo('Requested mode: foreground')
        start_app(port, app_settings, handlers_settings)
    else:
        click.echo('Requested mode: background')
        # subprocess.call([sys.executable, 'yourscript.py'], env=os.environ.copy())
        raise NotImplementedError
44003
def run
      if ref.nil?
        puts "That is not a valid shard reference."
        return
      end

      if Shard::Credentials.saved? && Shard::Credentials.valid?
        fork_shard
      else
        puts "You are not currently logged into Github."
        Shard::CLI::Config.run

        if Shard::Credentials.saved?
          run
        end
      end
    end
314641
def run(self):
        '''
        
        '''

        # Parse the stdin into a global event object
        stdin = self.read_stdin()
        self.event = self.read_event(stdin)

        # Prepare global settings
        self.settings = get_settings()
        self.api_settings = self.get_api_settings()

        # Prepare command line arguments and
        self.parser = argparse.ArgumentParser()

        # set up the 2.x to 1.x event mapping argument
        self.parser.add_argument("--map-v2-event-into-v1",
                                 action="store_true",
                                 default=False,
                                 dest="v2event")

        if hasattr(self, 'setup'):
            self.setup()
        (self.options, self.remain) = self.parser.parse_known_args()

        # map the event if required
        if (self.options.v2event or
                os.environ.get("SENSU_MAP_V2_EVENT_INTO_V1")):
            self.event = map_v2_event_into_v1(self.event)

        # Filter (deprecated) and handle
        self.filter()
        self.handle()
720431
def launch(run=True, **args):
    """"""

    verbosity['console'] = args['log'] if not args['quiet'] else 100
    verbosity['global'] = min(args['log'], args['logfileverbosity'])
    verbosity['file'] = args['logfileverbosity'] if args['dolog'] else 100
    set_logfile(args['logfilepath'], args['instance'])

    if args['livelog'] is True:
        from hfos import logger
        logger.live = True

    hfoslog("Running with Python", sys.version.replace("\n", ""),
            sys.platform, lvl=debug, emitter='CORE')
    hfoslog("Interpreter executable:", sys.executable, emitter='CORE')
    if args['cert'] is not None:
        hfoslog("Warning! Using SSL without nginx is currently not broken!",
                lvl=critical, emitter='CORE')

    hfoslog("Initializing database access", emitter='CORE', lvl=debug)
    initialize(args['dbhost'], args['dbname'], args['instance'])

    server = construct_graph(args)
    if run and not args['norun']:
        server.run()

    return server
175033
def run(self):
        
        server_address = (self.host, self.port)
        threading = True
        if threading:
            httpd_cls = type('WSGIServer', (ThreadingMixIn, WSGIServer), {})
        else:
            httpd_cls = WSGIServer
        self.httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=False)
        wsgi_handler = get_internal_wsgi_application()
        self.httpd.set_app(wsgi_handler)
        self.is_ready.set()
        self.httpd.serve_forever()
23865
def run(self):
        
        self.configure()
        self.setup()
        self.update_dir()
        db.init_db(drop_all=True)
        self.out.log("Starting up the server...")
        config = get_config()
        with HerokuLocalWrapper(config, self.out, verbose=self.verbose) as wrapper:
            try:
                self.execute(wrapper)
            except KeyboardInterrupt:
                pass
            finally:
                os.chdir(self.original_dir)
                self.cleanup()