Пример #1
0
def main():
    "Dispatch"
    opts = parse_args()
    opts = load_defaults(opts)
    configure_logging(opts.debug, opts.deploy_settings.logging)
    log = logging.getLogger('yodeploy')
    log.debug('Running: %r', sys.argv)

    cmd = globals().get('do_%s' % opts.command.replace('-', '_'))
    if cmd:
        cmd(opts)
    else:
        log.error('Unsupported command: %s', opts.command)
        sys.exit(1)
Пример #2
0
    def load_config(self):
        config = self.application.config
        parser = argparse.ArgumentParser(description='Yodeploy server')

        parser.add_argument('--listen', '-l', help='Bind to this IP address',
                            default='0.0.0.0')
        parser.add_argument('--port', '-p', type=int,
                            default=config.server.port,
                            help='Port to listen on (default: %s)'
                                 % config.server.port)
        parser.add_argument('--debug', '-d', action='store_true',
                            help='Increase verbosity')

        opts = parser.parse_args()

        configure_logging(opts.debug, config.server.logging)

        self.cfg.set('bind', '{}:{}'.format(opts.listen, opts.port))
        self.cfg.set('ciphers', config.server.ssl.ciphers)
        self.cfg.set('certfile', config.server.ssl.cert_chain)
        self.cfg.set('keyfile', config.server.ssl.key)
        self.cfg.set('workers', config.server.workers)
Пример #3
0
log = logging.getLogger('yodeploy')


def parse_args(flask_app):
    parser = argparse.ArgumentParser(description='Yodeploy server')

    parser.add_argument('--listen', '-l', help='Bind to this IP address',
                        default='0.0.0.0')
    parser.add_argument('--port', '-p', type=int,
                        default=flask_app.config.server.port,
                        help='Port to listen on (default: %s)' %
                             flask_app.config.server.port)
    parser.add_argument('--debug', '-d', action='store_true',
                        help='Increase verbosity')

    opts = parser.parse_args()

    return opts


if __name__ == '__main__':
    flask_app = create_app(find_deploy_config())
    opts = parse_args(flask_app)
    configure_logging(opts.debug, flask_app.config.server.logging)
    context = SSL.Context(SSL.SSLv23_METHOD)
    context.use_certificate_chain_file(flask_app.config.server.ssl.cert_chain)
    context.use_privatekey_file(flask_app.config.server.ssl.key)
    flask_app.config.deploy_config_fn = find_deploy_config()
    log.debug('Starting yodeploy server')
    flask_app.run(host=opts.listen, port=opts.port, ssl_context=context)