Skip to content

Instantly share code, notes, and snippets.

@viggy28
Last active August 10, 2019 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viggy28/e3de61a2070f6171c966b16dc36a1d32 to your computer and use it in GitHub Desktop.
Save viggy28/e3de61a2070f6171c966b16dc36a1d32 to your computer and use it in GitHub Desktop.
Keeping up haproxy config up to date with stolon on MacOS using https://github.com/UnitedTraders/stolon-standby-haproxy
postgres_haproxy_port: 7432
postgres_haproxy_config: '/Users/viggy28/haproxy/stolon_standby.cfg'
haproxy_reload_command: 'launchctl kickstart -k gui/501/viggy28.haproxy'
timeout: 60
# /Users/viggy28/haproxy/stolon_standby.cfg
frontend stolon_standby_frontend
mode tcp
bind *:7432
use_backend stolon_standby_backend
backend stolon_standby_backend
mode tcp
balance roundrobin
server stolon_standby_1 127.0.0.1:5432
# /Users/viggy28/Library/LaunchAgents/viggy28.haproxy.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>viggy28.haproxy</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/haproxy</string>
<string>-f</string>
<string>/Users/viggy28/haproxy/stolon_standby.cfg</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/viggy28/haproxy/error.log</string>
<key>StandardOutPath</key>
<string>/Users/viggy28/haproxy/output.log</string>
</dict>
</plist>
@viggy28
Copy link
Author

viggy28 commented Aug 10, 2019

Note: Remove the comments in the file which has an absolute path.

  1. Using launchctl:
       launchctl load /Users/viggy28/Library/LaunchAgents/viggy28.haproxy.plist
       launchctl start viggy28.haproxy
       -- To stop the service
       launchctl unload viggy28.haproxy.plist
       launchctl stop viggy28.haproxy

pgbouncer config (config.ini)

[databases]
postgres = host=127.0.0.1 port=7432 dbname=postgres

[pgbouncer]
pool_mode = session
listen_port = 6432
listen_addr = 127.0.0.1
auth_type = md5
auth_file = /Users/viggy28/pgbouncer/users.txt
auth_user = stupid
logfile = pgbouncer.log
pidfile = pgbouncer.pid
admin_users = viggy28
stats_users = stat_collector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment