sprint20-23: tests + documentation + guest access + infrastructure + migrations 0059
This commit is contained in:
@@ -0,0 +1,298 @@
|
||||
--
|
||||
-- Audit Log Partitioning Setup for LeoCRM
|
||||
-- =========================================
|
||||
--
|
||||
-- This script creates a partitioned audit_log table with monthly partitions.
|
||||
-- It includes functions for automatic partition creation and maintenance.
|
||||
--
|
||||
-- Usage:
|
||||
-- psql -h localhost -U leocrm -d crm_db -f scripts/setup_audit_partitioning.sql
|
||||
--
|
||||
-- The script is idempotent — safe to run multiple times.
|
||||
--
|
||||
|
||||
BEGIN;
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 1. Create the partitioned audit_log table
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
-- Check if the partitioned table already exists
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_class WHERE relname = 'audit_log' AND relkind = 'p'
|
||||
) THEN
|
||||
-- Check if there's an existing non-partitioned table
|
||||
IF EXISTS (SELECT 1 FROM pg_class WHERE relname = 'audit_log' AND relkind = 'r') THEN
|
||||
-- Rename existing table
|
||||
ALTER TABLE audit_log RENAME TO audit_log_old;
|
||||
RAISE NOTICE 'Renamed existing audit_log to audit_log_old';
|
||||
END IF;
|
||||
|
||||
-- Create the partitioned table
|
||||
CREATE TABLE audit_log (
|
||||
id UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||
tenant_id UUID,
|
||||
user_id UUID,
|
||||
action VARCHAR(100) NOT NULL,
|
||||
entity_type VARCHAR(50),
|
||||
entity_id UUID,
|
||||
changes JSONB,
|
||||
ip_address VARCHAR(45),
|
||||
user_agent TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
PRIMARY KEY (id, created_at)
|
||||
) PARTITION BY RANGE (created_at);
|
||||
|
||||
RAISE NOTICE 'Created partitioned audit_log table';
|
||||
END IF;
|
||||
END
|
||||
$$;
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 2. Function: Create a single monthly partition
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
CREATE OR REPLACE FUNCTION create_monthly_audit_partition(
|
||||
partition_date DATE DEFAULT CURRENT_DATE
|
||||
)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
DECLARE
|
||||
year_str TEXT;
|
||||
month_str TEXT;
|
||||
partition_name TEXT;
|
||||
start_date TEXT;
|
||||
end_date TEXT;
|
||||
BEGIN
|
||||
year_str := TO_CHAR(partition_date, 'YYYY');
|
||||
month_str := TO_CHAR(partition_date, 'MM');
|
||||
partition_name := 'audit_log_' || year_str || '_' || month_str;
|
||||
start_date := year_str || '-' || month_str || '-01';
|
||||
end_date := TO_CHAR(partition_date + INTERVAL '1 month', 'YYYY-MM-DD');
|
||||
|
||||
-- Check if partition already exists
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_class WHERE relname = partition_name
|
||||
) THEN
|
||||
EXECUTE format('
|
||||
CREATE TABLE %I PARTITION OF audit_log
|
||||
FOR VALUES FROM (%L) TO (%L)',
|
||||
partition_name, start_date, end_date
|
||||
);
|
||||
|
||||
-- Create indexes on the new partition
|
||||
EXECUTE format('
|
||||
CREATE INDEX %I ON %I (tenant_id)',
|
||||
'idx_' || partition_name || '_tenant', partition_name
|
||||
);
|
||||
EXECUTE format('
|
||||
CREATE INDEX %I ON %I (action)',
|
||||
'idx_' || partition_name || '_action', partition_name
|
||||
);
|
||||
EXECUTE format('
|
||||
CREATE INDEX %I ON %I (entity_type, entity_id)',
|
||||
'idx_' || partition_name || '_entity', partition_name
|
||||
);
|
||||
EXECUTE format('
|
||||
CREATE INDEX %I ON %I (created_at DESC)',
|
||||
'idx_' || partition_name || '_created', partition_name
|
||||
);
|
||||
|
||||
RAISE NOTICE 'Created partition: %', partition_name;
|
||||
ELSE
|
||||
RAISE NOTICE 'Partition already exists: %', partition_name;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 3. Function: Create partitions for the next N months
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
CREATE OR REPLACE FUNCTION create_future_audit_partitions(
|
||||
months_ahead INT DEFAULT 3
|
||||
)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
DECLARE
|
||||
i INT;
|
||||
partition_date DATE;
|
||||
BEGIN
|
||||
-- Create current month partition first
|
||||
partition_date := DATE_TRUNC('month', CURRENT_DATE)::DATE;
|
||||
PERFORM create_monthly_audit_partition(partition_date);
|
||||
|
||||
-- Create future month partitions
|
||||
FOR i IN 1..months_ahead LOOP
|
||||
partition_date := (DATE_TRUNC('month', CURRENT_DATE) + (i || ' months')::INTERVAL)::DATE;
|
||||
PERFORM create_monthly_audit_partition(partition_date);
|
||||
END LOOP;
|
||||
|
||||
RAISE NOTICE 'Created % future partitions (current + % months)', months_ahead + 1, months_ahead;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 4. Function: Drop old partitions beyond retention period
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
CREATE OR REPLACE FUNCTION drop_old_audit_partitions(
|
||||
retention_months INT DEFAULT 12
|
||||
)
|
||||
RETURNS INT
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
DECLARE
|
||||
partition_record RECORD;
|
||||
drop_count INT := 0;
|
||||
cutoff_date DATE;
|
||||
BEGIN
|
||||
cutoff_date := DATE_TRUNC('month', CURRENT_DATE - (retention_months || ' months')::INTERVAL)::DATE;
|
||||
|
||||
FOR partition_record IN
|
||||
SELECT
|
||||
inhrelid::regclass AS partition_name,
|
||||
pg_get_expr(relpartbound, relid) AS partition_bound
|
||||
FROM pg_catalog.pg_inherits
|
||||
JOIN pg_class ON pg_class.oid = inhrelid
|
||||
WHERE inhparent = 'audit_log'::regclass
|
||||
LOOP
|
||||
-- Extract the upper bound date from the partition bound expression
|
||||
-- Format: FOR VALUES FROM ('2026-01-01') TO ('2026-02-01')
|
||||
IF partition_record.partition_bound ~ 'TO \(''([0-9]{4}-[0-9]{2}-[0-9]{2})' THEN
|
||||
DECLARE
|
||||
upper_date DATE;
|
||||
BEGIN
|
||||
upper_date := SUBSTRING(
|
||||
partition_record.partition_bound
|
||||
FROM 'TO \(''([0-9]{4}-[0-9]{2}-[0-9]{2})'
|
||||
)::DATE;
|
||||
|
||||
IF upper_date <= cutoff_date THEN
|
||||
EXECUTE format('DROP TABLE IF EXISTS %I', partition_record.partition_name);
|
||||
drop_count := drop_count + 1;
|
||||
RAISE NOTICE 'Dropped old partition: %', partition_record.partition_name;
|
||||
END IF;
|
||||
END;
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
RETURN drop_count;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 5. Create initial partitions (current + next 3 months)
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
SELECT create_future_audit_partitions(3);
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 6. Migrate existing data (if any)
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
old_count BIGINT;
|
||||
new_count BIGINT;
|
||||
BEGIN
|
||||
-- Check if old table exists and has data
|
||||
IF EXISTS (SELECT 1 FROM pg_class WHERE relname = 'audit_log_old') THEN
|
||||
EXECUTE 'SELECT COUNT(*) FROM audit_log_old' INTO old_count;
|
||||
|
||||
IF old_count > 0 THEN
|
||||
RAISE NOTICE 'Migrating % rows from audit_log_old...', old_count;
|
||||
|
||||
-- Insert data into partitioned table
|
||||
EXECUTE '
|
||||
INSERT INTO audit_log (
|
||||
id, tenant_id, user_id, action, entity_type,
|
||||
entity_id, changes, ip_address, user_agent, created_at
|
||||
)
|
||||
SELECT
|
||||
id, tenant_id, user_id, action, entity_type,
|
||||
entity_id, changes, ip_address, user_agent, created_at
|
||||
FROM audit_log_old
|
||||
';
|
||||
|
||||
EXECUTE 'SELECT COUNT(*) FROM audit_log' INTO new_count;
|
||||
RAISE NOTICE 'Migration complete: % rows migrated', new_count;
|
||||
|
||||
-- Verify data integrity
|
||||
IF old_count = new_count THEN
|
||||
RAISE NOTICE 'Data integrity verified: % rows match', old_count;
|
||||
ELSE
|
||||
RAISE WARNING 'Data mismatch: old=% rows, new=% rows', old_count, new_count;
|
||||
END IF;
|
||||
ELSE
|
||||
RAISE NOTICE 'No data to migrate in audit_log_old';
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 7. Verify setup
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
partition_count INT;
|
||||
table_type TEXT;
|
||||
BEGIN
|
||||
-- Check table type
|
||||
SELECT relkind INTO table_type FROM pg_class WHERE relname = 'audit_log';
|
||||
|
||||
IF table_type = 'p' THEN
|
||||
RAISE NOTICE 'audit_log is correctly set up as a partitioned table';
|
||||
ELSE
|
||||
RAISE WARNING 'audit_log is NOT a partitioned table (relkind=%)', table_type;
|
||||
END IF;
|
||||
|
||||
-- Count partitions
|
||||
SELECT COUNT(*) INTO partition_count
|
||||
FROM pg_catalog.pg_inherits
|
||||
WHERE inhparent = 'audit_log'::regclass;
|
||||
|
||||
RAISE NOTICE 'Number of partitions: %', partition_count;
|
||||
END;
|
||||
$$;
|
||||
|
||||
COMMIT;
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- Usage Examples
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
--
|
||||
-- Create partitions for the next 6 months:
|
||||
-- SELECT create_future_audit_partitions(6);
|
||||
--
|
||||
-- Drop partitions older than 12 months:
|
||||
-- SELECT drop_old_audit_partitions(12);
|
||||
--
|
||||
-- Create a specific month partition:
|
||||
-- SELECT create_monthly_audit_partition('2026-07-01'::DATE);
|
||||
--
|
||||
-- Check partition sizes:
|
||||
-- SELECT
|
||||
-- relname AS partition_name,
|
||||
-- pg_size_pretty(pg_total_relation_size(relid)) AS total_size
|
||||
-- FROM pg_catalog.pg_statio_user_tables
|
||||
-- WHERE relname LIKE 'audit_log_%'
|
||||
-- ORDER BY relname;
|
||||
--
|
||||
-- Check row counts per partition:
|
||||
-- SELECT
|
||||
-- relname AS partition_name,
|
||||
-- n_live_tup AS row_count
|
||||
-- FROM pg_catalog.pg_stat_user_tables
|
||||
-- WHERE relname LIKE 'audit_log_%'
|
||||
-- ORDER BY relname;
|
||||
--
|
||||
-- Cron job (run on 1st of each month at 2 AM):
|
||||
-- 0 2 1 * * /usr/bin/psql -h localhost -U leocrm -d crm_db -c "SELECT create_future_audit_partitions(3);"
|
||||
--
|
||||
Executable
+279
@@ -0,0 +1,279 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# PgBouncer Setup Script for LeoCRM
|
||||
# ===================================
|
||||
#
|
||||
# This script installs and configures PgBouncer for PostgreSQL connection pooling.
|
||||
# It creates the configuration files and starts the service.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/setup_pgbouncer.sh [--docker] [--password PASSWORD]
|
||||
#
|
||||
# Options:
|
||||
# --docker Configure for Docker Compose environment
|
||||
# --password PASS Set PostgreSQL password (default: from .env or prompt)
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# ─── Color Output ───
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
# ─── Default Values ───
|
||||
PGBOUNCER_VERSION="1.23.1"
|
||||
PGBOUNCER_PORT="6432"
|
||||
POOL_MODE="transaction"
|
||||
DEFAULT_POOL_SIZE="25"
|
||||
MAX_CLIENT_CONN="200"
|
||||
|
||||
# ─── Parse Arguments ───
|
||||
DOCKER_MODE=false
|
||||
POSTGRES_PASSWORD=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--docker)
|
||||
DOCKER_MODE=true
|
||||
shift
|
||||
;;
|
||||
--password)
|
||||
POSTGRES_PASSWORD="$2"
|
||||
shift 2
|
||||
;;
|
||||
--help)
|
||||
echo "Usage: $0 [--docker] [--password PASSWORD]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --docker Configure for Docker Compose environment"
|
||||
echo " --password PASS Set PostgreSQL password (default: from .env or prompt)"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
log_error "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# ─── Detect Environment ───
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
if [ -f "$PROJECT_DIR/.env" ]; then
|
||||
source "$PROJECT_DIR/.env"
|
||||
fi
|
||||
|
||||
if [ -z "$POSTGRES_PASSWORD" ]; then
|
||||
POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-}"
|
||||
fi
|
||||
|
||||
if [ -z "$POSTGRES_PASSWORD" ]; then
|
||||
read -s -p "Enter PostgreSQL password: " POSTGRES_PASSWORD
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# ─── Docker Mode ───
|
||||
if [ "$DOCKER_MODE" = true ]; then
|
||||
log_info "Configuring PgBouncer for Docker Compose..."
|
||||
|
||||
# Check if docker-compose.yml exists
|
||||
if [ ! -f "$PROJECT_DIR/docker-compose.yml" ]; then
|
||||
log_error "docker-compose.yml not found in $PROJECT_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if PgBouncer service already exists
|
||||
if grep -q "pgbouncer" "$PROJECT_DIR/docker-compose.yml" 2>/dev/null; then
|
||||
log_warn "PgBouncer service already exists in docker-compose.yml"
|
||||
else
|
||||
log_info "Adding PgBouncer service to docker-compose.yml..."
|
||||
|
||||
# Add PgBouncer service before the last line of services
|
||||
cat >> "$PROJECT_DIR/docker-compose.yml" << 'EOF'
|
||||
|
||||
pgbouncer:
|
||||
image: bitnami/pgbouncer:latest
|
||||
container_name: leocrm-pgbouncer
|
||||
ports:
|
||||
- "6432:6432"
|
||||
environment:
|
||||
- POSTGRESQL_HOST=crm-postgres
|
||||
- POSTGRESQL_PORT=5432
|
||||
- POSTGRESQL_USERNAME=leocrm
|
||||
- POSTGRESQL_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRESQL_DATABASE=crm_db
|
||||
- PGBOUNCER_POOL_MODE=transaction
|
||||
- PGBOUNCER_DEFAULT_POOL_SIZE=25
|
||||
- PGBOUNCER_MAX_CLIENT_CONN=200
|
||||
depends_on:
|
||||
- crm-postgres
|
||||
restart: unless-stopped
|
||||
EOF
|
||||
log_info "PgBouncer service added to docker-compose.yml"
|
||||
fi
|
||||
|
||||
log_info "Docker PgBouncer configuration complete!"
|
||||
log_info "Run 'docker-compose up -d pgbouncer' to start PgBouncer"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ─── Native Installation ───
|
||||
log_info "Installing PgBouncer v${PGBOUNCER_VERSION}..."
|
||||
|
||||
# Check if PgBouncer is already installed
|
||||
if command -v pgbouncer &>/dev/null; then
|
||||
log_info "PgBouncer is already installed: $(pgbouncer --version)"
|
||||
else
|
||||
# Install PgBouncer
|
||||
if command -v apt-get &>/dev/null; then
|
||||
apt-get update
|
||||
apt-get install -y pgbouncer
|
||||
elif command -v yum &>/dev/null; then
|
||||
yum install -y pgbouncer
|
||||
else
|
||||
log_error "Unsupported package manager. Install PgBouncer manually."
|
||||
exit 1
|
||||
fi
|
||||
log_info "PgBouncer installed successfully"
|
||||
fi
|
||||
|
||||
# ─── Create Configuration ───
|
||||
log_info "Creating PgBouncer configuration..."
|
||||
|
||||
PGBOUNCER_CONF_DIR="/etc/pgbouncer"
|
||||
mkdir -p "$PGBOUNCER_CONF_DIR"
|
||||
|
||||
# Generate md5 password hash
|
||||
PG_MD5_HASH=$(echo -n "md5$(echo -n "${POSTGRES_PASSWORD}leocrm" | md5sum | cut -d' ' -f1)")
|
||||
|
||||
# Create pgbouncer.ini
|
||||
cat > "${PGBOUNCER_CONF_DIR}/pgbouncer.ini" << INI
|
||||
[databases]
|
||||
leocrm = host=localhost port=5432 dbname=crm_db
|
||||
leocrm_test = host=localhost port=5432 dbname=leocrm_test
|
||||
|
||||
[pgbouncer]
|
||||
listen_addr = 0.0.0.0
|
||||
listen_port = ${PGBOUNCER_PORT}
|
||||
unix_socket_dir = /var/run/pgbouncer
|
||||
|
||||
auth_type = md5
|
||||
auth_file = ${PGBOUNCER_CONF_DIR}/userlist.txt
|
||||
|
||||
pool_mode = ${POOL_MODE}
|
||||
default_pool_size = ${DEFAULT_POOL_SIZE}
|
||||
max_client_conn = ${MAX_CLIENT_CONN}
|
||||
max_db_connections = 50
|
||||
|
||||
server_idle_timeout = 600
|
||||
server_lifetime = 3600
|
||||
client_idle_timeout = 1800
|
||||
query_timeout = 30
|
||||
|
||||
log_connections = 1
|
||||
log_disconnections = 1
|
||||
log_pooler_errors = 1
|
||||
stats_period = 60
|
||||
|
||||
listen_backlog = 128
|
||||
INI
|
||||
|
||||
log_info "Created ${PGBOUNCER_CONF_DIR}/pgbouncer.ini"
|
||||
|
||||
# Create userlist.txt
|
||||
cat > "${PGBOUNCER_CONF_DIR}/userlist.txt" << USERLIST
|
||||
"leocrm" "${PG_MD5_HASH}"
|
||||
"postgres" "${PG_MD5_HASH}"
|
||||
USERLIST
|
||||
|
||||
log_info "Created ${PGBOUNCER_CONF_DIR}/userlist.txt"
|
||||
|
||||
# Set proper permissions
|
||||
chmod 640 "${PGBOUNCER_CONF_DIR}/pgbouncer.ini"
|
||||
chmod 640 "${PGBOUNCER_CONF_DIR}/userlist.txt"
|
||||
chown -R pgbouncer:pgbouncer "$PGBOUNCER_CONF_DIR" 2>/dev/null || true
|
||||
|
||||
# ─── Create Systemd Service ───
|
||||
log_info "Creating systemd service..."
|
||||
|
||||
cat > /etc/systemd/system/pgbouncer.service << 'SYSTEMD'
|
||||
[Unit]
|
||||
Description=PgBouncer PostgreSQL Connection Pooler
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User=pgbouncer
|
||||
ExecStart=/usr/sbin/pgbouncer -d /etc/pgbouncer/pgbouncer.ini
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
ExecStop=/bin/kill -INT $MAINPID
|
||||
PIDFile=/var/run/pgbouncer/pgbouncer.pid
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
SYSTEMD
|
||||
|
||||
log_info "Created systemd service"
|
||||
|
||||
# ─── Start PgBouncer ───
|
||||
log_info "Starting PgBouncer..."
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable pgbouncer
|
||||
systemctl start pgbouncer
|
||||
|
||||
# Wait for PgBouncer to start
|
||||
sleep 2
|
||||
|
||||
# Check status
|
||||
if systemctl is-active --quiet pgbouncer; then
|
||||
log_info "PgBouncer is running on port ${PGBOUNCER_PORT}"
|
||||
else
|
||||
log_error "PgBouncer failed to start. Check logs: journalctl -u pgbouncer"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ─── Verify Connection ───
|
||||
log_info "Verifying PgBouncer connection..."
|
||||
|
||||
if command -v psql &>/dev/null; then
|
||||
if PGPASSWORD="$POSTGRES_PASSWORD" psql -h localhost -p "$PGBOUNCER_PORT" -U leocrm -d leocrm -c "SELECT 1 AS pgbouncer_test;" &>/dev/null; then
|
||||
log_info "PgBouncer connection verified successfully!"
|
||||
else
|
||||
log_warn "Could not verify PgBouncer connection. Check PostgreSQL credentials."
|
||||
fi
|
||||
fi
|
||||
|
||||
# ─── Summary ───
|
||||
echo ""
|
||||
echo "═══════════════════════════════════════════════"
|
||||
echo " PgBouncer Setup Complete"
|
||||
echo "═══════════════════════════════════════════════"
|
||||
echo ""
|
||||
echo " Configuration:"
|
||||
echo " Config file: ${PGBOUNCER_CONF_DIR}/pgbouncer.ini"
|
||||
echo " User list: ${PGBOUNCER_CONF_DIR}/userlist.txt"
|
||||
echo " Listen port: ${PGBOUNCER_PORT}"
|
||||
echo " Pool mode: ${POOL_MODE}"
|
||||
echo " Pool size: ${DEFAULT_POOL_SIZE}"
|
||||
echo ""
|
||||
echo " Commands:"
|
||||
echo " Status: systemctl status pgbouncer"
|
||||
echo " Restart: systemctl restart pgbouncer"
|
||||
echo " Reload: systemctl reload pgbouncer"
|
||||
echo " Stop: systemctl stop pgbouncer"
|
||||
echo ""
|
||||
echo " Monitoring:"
|
||||
echo " Pools: echo 'SHOW POOLS;' | psql -h localhost -p ${PGBOUNCER_PORT} -U leocrm -d pgbouncer"
|
||||
echo " Stats: echo 'SHOW STATS;' | psql -h localhost -p ${PGBOUNCER_PORT} -U leocrm -d pgbouncer"
|
||||
echo ""
|
||||
echo "═══════════════════════════════════════════════"
|
||||
Reference in New Issue
Block a user