Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. if [ "$PG_PORT" = "" ]; then
  4. PG_PORT=5432
  5. fi
  6.  
  7. if [ "$MIN_POOL_SIZE" = "" ]; then
  8. MIN_POOL_SIZE=0
  9. fi
  10.  
  11. if [ "$DEFAULT_POOL_SIZE" = "" ]; then
  12. DEFAULT_POOL_SIZE=20
  13. fi
  14.  
  15. if [ "$RESRVE_POOL_SIZE" = "" ]; then
  16. RESERVE_POOL_SIZE=0
  17. fi
  18.  
  19. if [ "$MAX_CONN" = "" ]; then
  20. MAX_CONN=1024
  21. fi
  22.  
  23. echo "Starting pgbouncer for $PG_USER@$PG_HOST:$PG_PORT/$PG_DATABASE"
  24. echo "Stats user: $STATS_USER"
  25. echo
  26.  
  27. mkdir -p /etc/pgbouncer
  28.  
  29. cat > /etc/pgbouncer/pgbouncer.ini <<EOF
  30. [databases]
  31. $PG_DATABASE = dbname=$PG_DATABASE host=$PG_HOST port=$PG_PORT user=$PG_USER password=$PG_PASS
  32. stats = dbname=$PG_DATABASE host=$PG_HOST port=$PG_PORT user=$STATS_USER password=$STATS_PASS
  33.  
  34. [pgbouncer]
  35. pool_mode = transaction
  36. listen_port = 5432
  37. listen_addr = 0.0.0.0
  38. auth_type = md5
  39. auth_file = /etc/pgbouncer/users
  40. admin_users = $PG_USER
  41. stats_users = $STATS_USER
  42. max_client_conn = $MAX_CONN
  43. min_pool_size = $MIN_POOL_SIZE
  44. default_pool_size = $DEFAULT_POOL_SIZE
  45. reserve_pool_size = $RESERVE_POOL_SIZE
  46. ignore_startup_parameters = extra_float_digits
  47. EOF
  48.  
  49. cat > /etc/pgbouncer/users <<EOF
  50. "$PG_USER" "$PG_PASS"
  51. "$STATS_USER" "$STATS_PASS"
  52. EOF
  53.  
  54. exec /usr/bin/pgbouncer /etc/pgbouncer/pgbouncer.ini
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement