Commit dfc0253e authored by Gabriel Mazetto's avatar Gabriel Mazetto 🚀

Using unix socket instead of hardcoded host/port for PG replication

parent 9e135e5a
......@@ -5,6 +5,8 @@ gitlab_workhorse_repo = https://gitlab.com/gitlab-org/gitlab-workhorse.git
gitlab_development_root = $(shell pwd)
postgres_bin_dir = $(shell pg_config --bindir)
postgres_replication_user = gitlab_replication
postgres_dir = $(realpath ./postgresql)
postgres_replica_dir = $(realpath ./postgresql-replica)
all: gitlab-setup gitlab-shell-setup gitlab-runner-setup gitlab-workhorse-setup support-setup
......@@ -122,17 +124,17 @@ postgresql/data/PG_VERSION:
${postgres_bin_dir}/initdb --locale=C -E utf-8 postgresql/data
postgresql-replication/cluster:
${postgres_bin_dir}/initdb --locale=C -E utf-8 postgresql-replica/data && \
${postgres_bin_dir}/initdb --locale=C -E utf-8 postgresql-replica/data
cat support/pg_hba.conf.add >> postgresql/data/pg_hba.conf
postgresql-replication/role:
${postgres_bin_dir}/psql -h localhost -d postgres -c "CREATE ROLE ${postgres_replication_user} WITH REPLICATION LOGIN;"
${postgres_bin_dir}/psql -h ${postgres_dir} -d postgres -c "CREATE ROLE ${postgres_replication_user} WITH REPLICATION LOGIN;"
postgresql-replication/backup:
psql -h localhost -d postgres -c "select pg_start_backup('base backup for streaming rep')"
psql -h ${postgres_dir} -d postgres -c "select pg_start_backup('base backup for streaming rep')"
rsync -cva --inplace --exclude="*pg_xlog*" postgresql/data postgresql-replica
psql -h localhost -d postgres -c "select pg_stop_backup(), current_timestamp"
cp support/recovery.conf postgresql-replica/data
psql -h ${postgres_dir} -d postgres -c "select pg_stop_backup(), current_timestamp"
./support/recovery.conf ${postgres_dir} > postgresql-replica/data/recovery.conf
.bundle:
bundle install --jobs 4
......
redis: redis-server /home/git/redis/redis.conf
postgresql: postgres -D /home/git/postgresql/data -k /home/git/postgresql -h ''
#postgresql-replica: postgres -D /home/git/postgresql-replica/data -k /home/git/postgresql-replica -h ''
#openldap: cd gitlab-openldap && libexec/slapd -F slapd.d -d2 -h "ldap://127.0.0.1:3890"
gitlab-workhorse: /home/git/gitlab-workhorse/gitlab-workhorse -authSocket /home/git/gitlab.socket -listenAddr localhost:3000 -documentRoot /home/git/gitlab/public -developmentMode
host replication gitlab_replication 127.0.0.1/32 trust
host replication gitlab_replication ::1/128 trust
local replication gitlab_replication trust
#!/bin/bash
# this script will output a recovery.conf file using first parameter as host/socket path
socket_path=$1
cat <<EOF
standby_mode = 'on'
primary_conninfo = 'host=localhost port=5432 user=gitlab_replication'
trigger_file = '/tmp/postgresql.trigger.5432'
primary_conninfo = 'host=${socket_path} port=5432 user=gitlab_replication'
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment