Commit 80442a6c authored by Kirill Smelkov's avatar Kirill Smelkov

X Checkpoint on embedded postgresql

parent be3a23b0
...@@ -29,6 +29,7 @@ import md5 ...@@ -29,6 +29,7 @@ import md5
import os import os
import subprocess import subprocess
import textwrap import textwrap
import shutil
from zc.buildout import UserError from zc.buildout import UserError
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe
...@@ -79,11 +80,19 @@ class Recipe(GenericBaseRecipe): ...@@ -79,11 +80,19 @@ class Recipe(GenericBaseRecipe):
# if the pgdata already exists, skip all steps, we don't need to do anything. # if the pgdata already exists, skip all steps, we don't need to do anything.
if not os.path.exists(pgdata): if not os.path.exists(pgdata):
try:
self.createCluster() self.createCluster()
self.createConfig() self.createConfig()
self.createDatabase() self.createDatabase()
self.updateSuperuser() self.updateSuperuser()
self.createRunScript() self.createRunScript()
except:
# do not leave half-installed postgresql - else next time we
# run we won't update it.
shutil.rmtree(pgdata)
raise
# install() methods usually return the pathnames of managed files. # install() methods usually return the pathnames of managed files.
# If they are missing, they will be rebuilt. # If they are missing, they will be rebuilt.
......
...@@ -9,7 +9,6 @@ parts = ...@@ -9,7 +9,6 @@ parts =
publish-instance-info publish-instance-info
# request-postgresql
gitlab-rails gitlab-rails
gitlab-rake gitlab-rake
gitlab-unicorn gitlab-unicorn
...@@ -17,8 +16,10 @@ parts = ...@@ -17,8 +16,10 @@ parts =
gitlab-root-shadow gitlab-root-shadow
service-nginx service-nginx
service-postgresql
# service-redis
# std stuff for slapos instance # std stuff for slapos instance
eggs-directory = {{ eggs_directory }} eggs-directory = {{ eggs_directory }}
...@@ -68,33 +69,35 @@ recipe = slapos.cookbook:publish ...@@ -68,33 +69,35 @@ recipe = slapos.cookbook:publish
url = ${gitlab-backend:url} url = ${gitlab-backend:url}
# TODO reintegrate postgresql/redis into this instance {#
################################# # # TODO reintegrate postgresql/redis into this instance
# need: PostgreSQL instance # # #################################
################################# # # need: PostgreSQL instance #
[request-postgresql] # #################################
<= slap-connection # [request-postgresql]
recipe = slapos.cookbook:request # <= slap-connection
# TODO name = $(gitlab-name)/pgsql # recipe = slapos.cookbook:request
name = g-pgsql # # TODO name = $(gitlab-name)/pgsql
software-url = {{ urlparse.urljoin(software_release_url, '../postgres/software.cfg') }} # name = g-pgsql
return = url # software-url = {{ urlparse.urljoin(software_release_url, '../postgres/software.cfg') }}
# return = url
[postgresql-urlparse] #
recipe = slapos.cookbook:urlparse # [postgresql-urlparse]
url = ${request-postgresql:connection-url} # recipe = slapos.cookbook:urlparse
# url = ${request-postgresql:connection-url}
#
############################ #
# need: Redis instance # # ############################
############################ # # need: Redis instance #
[request-redis] # ############################
<= slap-connection # [request-redis]
recipe = slapos.cookbook:request # <= slap-connection
# TODO name = $(gitlab-name)/pgsql # recipe = slapos.cookbook:request
name = g-redis # # TODO name = $(gitlab-name)/pgsql
software-url = {{ urlparse.urljoin(software_release_url, '../redis-server/software.cfg') }} # name = g-redis
return = redis_ip redis_port # software-url = {{ urlparse.urljoin(software_release_url, '../redis-server/software.cfg') }}
# return = redis_ip redis_port
#}
...@@ -161,7 +164,8 @@ rendered= ${gitlab:etc}/${:_buildout_section_name_} ...@@ -161,7 +164,8 @@ rendered= ${gitlab:etc}/${:_buildout_section_name_}
<= gitlab-etc-template <= gitlab-etc-template
template= {{ database_yml_in }} template= {{ database_yml_in }}
context = context =
section pgsql postgresql-urlparse section gitlab_backend gitlab-backend
section pgsql service-postgresql
[gitlab.yml] [gitlab.yml]
<= gitlab-etc-template <= gitlab-etc-template
...@@ -174,8 +178,8 @@ context = ...@@ -174,8 +178,8 @@ context =
[resque.yml] [resque.yml]
<= gitlab-etc-template <= gitlab-etc-template
template= {{ resque_yml_in }} template= {{ resque_yml_in }}
context = #context =
section redis request-redis # section redis request-redis
[smtp_settings.rb] [smtp_settings.rb]
<= gitlab-etc-template <= gitlab-etc-template
...@@ -326,6 +330,52 @@ command = ...@@ -326,6 +330,52 @@ command =
# sidekiq # sidekiq
#####################
# Postgresql db #
#####################
#[postgresql]
#recipe = slapos.cookbook:mkdirectory
#srv = ${directory:srv}/postgresql
# XXX etc - no
# XXX log
[postgresql-password]
recipe = slapos.cookbook:generate.password
storage-path = ...
# XXX gitlab tunes:
# - shared_buffers
# - work_mem
# - checkpoint_*
# - effective_check_size
# - lc_* en_US.UTF-8 -> C (?)
[service-postgresql]
recipe = slapos.cookbook:postgres
bin = {{ postgresql_location }}/bin
services= ${directory:service}
dbname = gitlabhq_production
superuser = gitlab
# TODO password
password= ...
# empty addresses - listn only on unix socket
ipv4 = !py!set([])
ipv6 = !py!set([])
ipv6-random =
port =
pgdata-directory = ${directory:srv}/postgresql
#############
# Redis #
#############
###################### ######################
# Nginx frontend # # Nginx frontend #
###################### ######################
......
...@@ -34,6 +34,7 @@ context = ...@@ -34,6 +34,7 @@ context =
raw git ${git:location}/bin/git raw git ${git:location}/bin/git
raw nginx_bin ${nginx-output:nginx} raw nginx_bin ${nginx-output:nginx}
raw mime_types ${nginx-output:mime} raw mime_types ${nginx-output:mime}
raw postgresql_location ${postgresql92:location}
raw macrolib_cfg_in ${macrolib.cfg.in:target} raw macrolib_cfg_in ${macrolib.cfg.in:target}
raw gitlab_parameters_cfg ${gitlab-parameters.cfg:target} raw gitlab_parameters_cfg ${gitlab-parameters.cfg:target}
......
...@@ -5,6 +5,7 @@ extends = ...@@ -5,6 +5,7 @@ extends =
../../component/ruby/buildout.cfg ../../component/ruby/buildout.cfg
../../component/golang/buildout.cfg ../../component/golang/buildout.cfg
../../component/postgresql/buildout.cfg ../../component/postgresql/buildout.cfg
../../component/redis/buildout.cfg
../../component/cmake/buildout.cfg ../../component/cmake/buildout.cfg
../../component/icu/buildout.cfg ../../component/icu/buildout.cfg
../../component/pkgconfig/buildout.cfg ../../component/pkgconfig/buildout.cfg
...@@ -16,6 +17,7 @@ parts = ...@@ -16,6 +17,7 @@ parts =
ruby2.1 ruby2.1
git git
postgresql92 postgresql92
redis28
cmake cmake
icu icu
pkgconfig pkgconfig
......
...@@ -6,11 +6,10 @@ ...@@ -6,11 +6,10 @@
production: production:
adapter: postgresql adapter: postgresql
encoding: unicode encoding: unicode
#database: gitlabhq_production database: {{ pgsql.dbname }}
database: {{ pgsql.path }}
pool: 10 pool: 10
username: '{{ pgsql.username }}' username: '{{ pgsql.superuser }}'
password: '{{ pgsql.password }}' password:
host: {{ pgsql.host }} host: '{{ pgsql["pgdata-directory"] }}'
port: {{ pgsql.port }} port:
# socket: socket:
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
# https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/resque.yml.example # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/resque.yml.example
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/resque.yml.erb # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/resque.yml.erb
production: redis://[{{ redis['connection-redis_ip'] }}]:{{ redis['connection-redis_port'] }} {# production: redis://[{{ redis['connection-redis_ip'] }}]:{{ redis['connection-redis_port'] }} #}
production: redis://127.0.0.1:12345
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