Improve openrc init script, add port setting
* Ensure the log directory exists with openrc * Add a port setting to configure the port the agent listens on * Switch to RealDictCursor * Fix type for connection timeout
This commit is contained in:
@@ -11,7 +11,7 @@ import logging
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import psycopg2
|
||||
from psycopg2.extras import DictCursor
|
||||
from psycopg2.extras import RealDictCursor
|
||||
from psycopg2.pool import ThreadedConnectionPool
|
||||
|
||||
from contextlib import contextmanager
|
||||
@@ -70,6 +70,9 @@ class MetricVersionError(Exception):
|
||||
|
||||
# Default config settings
|
||||
default_config = {
|
||||
# The port the agent listens on for requests
|
||||
'port': 5400,
|
||||
|
||||
# Min PostgreSQL connection pool size (per database)
|
||||
'min_pool_size': 0,
|
||||
|
||||
@@ -296,7 +299,7 @@ def get_pool(dbname):
|
||||
host=config['dbhost'],
|
||||
port=config['dbport'],
|
||||
user=config['dbuser'],
|
||||
connect_timeout=float(config['connect_timeout']),
|
||||
connect_timeout=int(config['connect_timeout']),
|
||||
sslmode='require')
|
||||
# Clear the unhappy indicator if present
|
||||
unhappy_cooldown.pop(dbname, None)
|
||||
@@ -333,7 +336,7 @@ def run_query_no_retry(pool, return_type, query, args):
|
||||
"""
|
||||
with pool.connection(float(config['connect_timeout'])) as conn:
|
||||
try:
|
||||
with conn.cursor(cursor_factory=DictCursor) as curs:
|
||||
with conn.cursor(cursor_factory=RealDictCursor) as curs:
|
||||
curs.execute(query, args)
|
||||
res = curs.fetchall()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user