(server)
Start metrics server when Timesketch app is ready.
Start metrics server when Timesketch app is ready.
Start metrics server when Timesketch app is ready .
def when_ready(server):
    """Start metrics server when Timesketch app is ready."""
    # Exit early if we don't have the necessary environment set up.
    if not METRICS_ENABLED:
        return

    # Clean up andy old prometheus database files
    if os.path.isdir(METRICS_DB_DIR):
        files = glob.glob(METRICS_DB_DIR + '/*.db')
        for file in files:
            os.remove(file)
    else:
        pathlib.Path(METRICS_DB_DIR).mkdir(parents=True, exist_ok=True)

    GunicornPrometheusMetrics.start_http_server_when_ready(
        int(METRICS_HTTP_PORT), METRICS_HTTP_HOST)
def when_ready ( server ) : # Exit early if we don't have the necessary environment set up. if not METRICS_ENABLED : return # Clean up andy old prometheus database files if os . path . isdir ( METRICS_DB_DIR ) : files = glob . glob ( METRICS_DB_DIR + '/*.db' ) for file in files : os . remove ( file ) else : pathlib . Path ( METRICS_DB_DIR ) . mkdir ( parents = True , exist_ok = True ) GunicornPrometheusMetrics . start_http_server_when_ready ( int ( METRICS_HTTP_PORT ) , METRICS_HTTP_HOST )