diff --git a/.gitignore b/.gitignore index 6885722eaf20871d547f17f3c62369ed7e593e1f..dd7acbaca5f3874f3957341657da19fb67af3c06 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /Procfile /postgresql/data /postgresql/.s.* +/postgresql-geo/ /postgresql-primary/ /postgresql-replica/data /postgresql-replica/.s.* diff --git a/Makefile b/Makefile index b94c7eb794ea513b6ab6fe7ceb027ce2e8ac9c96..b663de04d4e874c78a6d5a5d88a13124444d998f 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ postgres_bin_dir = $(shell pg_config --bindir) postgres_replication_user = gitlab_replication postgres_dir = $(realpath ./postgresql) postgres_replica_dir = $(realpath ./postgresql-replica) +postgres_geo_dir = $(realpath ./postgresql-geo) port = $(shell cat port 2>/dev/null) username = $(shell whoami) sshd_bin = $(shell which sshd) @@ -187,6 +188,19 @@ postgresql-replication/backup: postgresql-replication/config: ./support/postgres-replication ${postgres_dir} +# Setup GitLab Geo databases + +.PHONY: geo-setup +geo-setup: gitlab/config/database_geo.yml postgresql/geo + +gitlab/config/database_geo.yml: + sed "s|/home/git|${gitlab_development_root}|" database_geo.yml.example > gitlab/config/database_geo.yml + +postgresql/geo: + ${postgres_bin_dir}/initdb --locale=C -E utf-8 postgresql-geo/data + grep '^postgresql-geo:' Procfile || (printf ',s/^#postgresql-geo/postgresql-geo/\nwq\n' | ed -s Procfile) + support/bootstrap-geo + .PHONY: foreman foreman: command -v $@ > /dev/null || gem install $@ diff --git a/Procfile.example b/Procfile.example index 33f02f60560e204bec1f6b7641b731033b43c075..76bb1a157af8def5c9c5d89096521af62ee4e1c4 100644 --- a/Procfile.example +++ b/Procfile.example @@ -5,6 +5,7 @@ redis: exec redis-server /home/git/redis/redis.conf postgresql: exec support/postgresql-signal-wrapper postgres -D /home/git/postgresql/data -k /home/git/postgresql -h '' #postgresql-replica: exec support/postgresql-signal-wrapper postgres -D /home/git/postgresql-replica/data -k /home/git/postgresql-replica -h '' +#postgresql-geo: exec support/postgresql-signal-wrapper postgres -D /home/git/postgresql-geo/data -k /home/git/postgresql-geo -h '' #openldap: exec support/exec-cd gitlab-openldap libexec/slapd -F slapd.d -d2 -h "ldap://$host:3890" gitlab-workhorse: exec /usr/bin/env PATH="/home/git/gitlab-workhorse/bin:$PATH" gitlab-workhorse -authSocket /home/git/gitlab.socket -listenAddr $host:$port -documentRoot /home/git/gitlab/public -developmentMode -secretPath /home/git/gitlab/.gitlab_workhorse_secret -config /home/git/gitlab-workhorse/config.toml rails-web: exec /usr/bin/env RAILS_ENV=development support/exec-cd gitlab bin/web start_foreground diff --git a/database_geo.yml.example b/database_geo.yml.example new file mode 100644 index 0000000000000000000000000000000000000000..9cb28f4b4e3ab14dff950e606f7fb52a23341f15 --- /dev/null +++ b/database_geo.yml.example @@ -0,0 +1,13 @@ +development: + adapter: postgresql + encoding: unicode + database: gitlabhq_geo_development + pool: 5 + host: /home/git/postgresql-geo + +test: &test + adapter: postgresql + encoding: unicode + database: gitlabhq_geo_test + pool: 5 + host: /home/git/postgresql-geo diff --git a/doc/set-up-gdk.md b/doc/set-up-gdk.md index 4f191a836514976c06681d863375aa13393bffdf..9a2772506cb2fe39a42d0b99cbb3024f742f2fa1 100644 --- a/doc/set-up-gdk.md +++ b/doc/set-up-gdk.md @@ -86,6 +86,7 @@ cd gdk-geo echo 3002 > port echo 3807 > webpack_port gdk install gitlab_repo=https://gitlab.com/gitlab-org/gitlab-ee.git +make geo-setup ``` Now that you've installed a primary and a secondary GDK instance, follow the diff --git a/run b/run index 95b1f99c0146697c05e1d4c97d3939fb39ccf9e1..cce396b9b5ee2d68a3b89ff07a40365c26c0a06a 100755 --- a/run +++ b/run @@ -53,6 +53,10 @@ db() { foreman_start -c all=0,redis=1,postgresql=1,openldap=1,influxdb=1,webpack=1 } +geo_db() { + foreman_start -c all=0,postgresql-geo=1 +} + app() { print_port foreman_start -c all=0,rails-web=1,rails-background-jobs=1,gitlab-workhorse=1,nginx=1,grafana=1,sshd=1,gitaly=1 @@ -75,6 +79,9 @@ case "x$1" in xdb) db ;; +xgeo_db) + geo_db + ;; xapp) app ;; diff --git a/support/bootstrap-geo b/support/bootstrap-geo new file mode 100755 index 0000000000000000000000000000000000000000..98163d80356bfe75f52bb616912ac9a8c9ef4f5c --- /dev/null +++ b/support/bootstrap-geo @@ -0,0 +1,19 @@ +#!/usr/bin/env ruby + +success = true +begin + foreman_pid = spawn('./run', 'geo_db') + [ + %W(bundle exec rake geo:db:setup) + ].each do |cmd| + success &&= system({'force' => 'yes', 'BOOTSTRAP' => '1'}, *cmd, chdir: 'gitlab') + end +ensure + Process.kill('TERM', foreman_pid) +end + +Process.wait(foreman_pid) + +exit true if success + +abort "#$0 failed"