| 68 | |
| 69 | |
| 70 | def _run_server(): |
| 71 | host = cfg.CONF.auth.host |
| 72 | port = cfg.CONF.auth.port |
| 73 | use_ssl = cfg.CONF.auth.use_ssl |
| 74 | |
| 75 | cert_file_path = os.path.realpath(cfg.CONF.auth.cert) |
| 76 | key_file_path = os.path.realpath(cfg.CONF.auth.key) |
| 77 | |
| 78 | if use_ssl and not os.path.isfile(cert_file_path): |
| 79 | raise ValueError('Certificate file "%s" doesn\'t exist' % (cert_file_path)) |
| 80 | |
| 81 | if use_ssl and not os.path.isfile(key_file_path): |
| 82 | raise ValueError('Private key file "%s" doesn\'t exist' % (key_file_path)) |
| 83 | |
| 84 | socket = eventlet.listen((host, port)) |
| 85 | |
| 86 | if use_ssl: |
| 87 | socket = eventlet.wrap_ssl( |
| 88 | socket, certfile=cert_file_path, keyfile=key_file_path, server_side=True |
| 89 | ) |
| 90 | |
| 91 | LOG.info('ST2 Auth API running in "%s" auth mode', cfg.CONF.auth.mode) |
| 92 | LOG.info( |
| 93 | "(PID=%s) ST2 Auth API is serving on %s://%s:%s.", |
| 94 | os.getpid(), |
| 95 | "https" if use_ssl else "http", |
| 96 | host, |
| 97 | port, |
| 98 | ) |
| 99 | |
| 100 | wsgi.server(socket, app.setup_app(), log=LOG, log_output=False) |
| 101 | return 0 |
| 102 | |
| 103 | |
| 104 | def _teardown(): |