Commit ec01997c authored by Kirill Smelkov's avatar Kirill Smelkov

X on embedded redis

parent 80442a6c
...@@ -45,6 +45,11 @@ class Recipe(GenericBaseRecipe): ...@@ -45,6 +45,11 @@ class Recipe(GenericBaseRecipe):
log_file=self.options['log_file'], log_file=self.options['log_file'],
master_passwd=master_passwd master_passwd=master_passwd
) )
if self.options.get('unixsocket'):
unixsocket = "unixsocket %s\nunixsocketperm 700" % self.options['unixsocket']
else:
unixsocket = ""
configuration['unixsocket'] = unixsocket
config = self.createFile(config_file, config = self.createFile(config_file,
self.substituteTemplate(self.getTemplateFilename('redis.conf.in'), self.substituteTemplate(self.getTemplateFilename('redis.conf.in'),
...@@ -63,7 +68,8 @@ class Recipe(GenericBaseRecipe): ...@@ -63,7 +68,8 @@ class Recipe(GenericBaseRecipe):
promise = self.createPythonScript( promise = self.createPythonScript(
promise_script, promise_script,
'%s.promise.main' % __name__, '%s.promise.main' % __name__,
dict(host=self.options['ipv6'], port=self.options['port']) dict(host=self.options['ipv6'], port=self.options['port'],
unixsocket = self.options.get('unixsocket') )
) )
path_list.append(promise) path_list.append(promise)
......
...@@ -7,12 +7,14 @@ import sys ...@@ -7,12 +7,14 @@ import sys
def main(args): def main(args):
host = args['host'] host = args['host']
port = int(args['port']) port = int(args['port'])
unixsocket = args['unixsocket']
try: try:
pool = redis.ConnectionPool(host=host, port=port, db=0) #pool = redis.ConnectionPool(host=host, port=port, unix_socket_path=unixsocket, db=0)
r = redis.Redis(connection_pool=pool) #r = redis.Redis(connection_pool=pool)
r = redis.Redis(host=host, port=port, unix_socket_path=unixsocket, db=0)
r.publish("Promise-Service","SlapOS Promise") r.publish("Promise-Service","SlapOS Promise")
pool.disconnect() r.connection_pool.disconnect()
sys.exit(0) sys.exit(0)
except Exception, e: except Exception, e:
print str(e) print str(e)
sys.exit(1) sys.exit(1)
\ No newline at end of file
...@@ -72,9 +72,7 @@ bind %(ipv6)s ...@@ -72,9 +72,7 @@ bind %(ipv6)s
# Specify the path for the Unix socket that will be used to listen for # Specify the path for the Unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen # incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified. # on a unix socket when not specified.
# %(unixsocket)s
# unixsocket /tmp/redis.sock
# unixsocketperm 700
# Close the connection after a client is idle for N seconds (0 to disable) # Close the connection after a client is idle for N seconds (0 to disable)
timeout 0 timeout 0
......
...@@ -18,7 +18,7 @@ parts = ...@@ -18,7 +18,7 @@ parts =
service-nginx service-nginx
service-postgresql service-postgresql
# service-redis service-redis
# std stuff for slapos instance # std stuff for slapos instance
...@@ -69,38 +69,6 @@ recipe = slapos.cookbook:publish ...@@ -69,38 +69,6 @@ recipe = slapos.cookbook:publish
url = ${gitlab-backend:url} url = ${gitlab-backend:url}
{#
# # TODO reintegrate postgresql/redis into this instance
# #################################
# # need: PostgreSQL instance #
# #################################
# [request-postgresql]
# <= slap-connection
# recipe = slapos.cookbook:request
# # TODO name = $(gitlab-name)/pgsql
# name = g-pgsql
# software-url = {{ urlparse.urljoin(software_release_url, '../postgres/software.cfg') }}
# return = url
#
# [postgresql-urlparse]
# recipe = slapos.cookbook:urlparse
# url = ${request-postgresql:connection-url}
#
#
# ############################
# # need: Redis instance #
# ############################
# [request-redis]
# <= slap-connection
# recipe = slapos.cookbook:request
# # TODO name = $(gitlab-name)/pgsql
# name = g-redis
# software-url = {{ urlparse.urljoin(software_release_url, '../redis-server/software.cfg') }}
# return = redis_ip redis_port
#}
############################# #############################
# GitLab instance setup # # GitLab instance setup #
...@@ -178,8 +146,8 @@ context = ...@@ -178,8 +146,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 service-redis
[smtp_settings.rb] [smtp_settings.rb]
<= gitlab-etc-template <= gitlab-etc-template
...@@ -338,7 +306,7 @@ command = ...@@ -338,7 +306,7 @@ command =
#recipe = slapos.cookbook:mkdirectory #recipe = slapos.cookbook:mkdirectory
#srv = ${directory:srv}/postgresql #srv = ${directory:srv}/postgresql
# XXX etc - no # XXX etc - no
# XXX log # XXX log - goes to stdout/stderr
[postgresql-password] [postgresql-password]
recipe = slapos.cookbook:generate.password recipe = slapos.cookbook:generate.password
...@@ -361,20 +329,46 @@ superuser = gitlab ...@@ -361,20 +329,46 @@ superuser = gitlab
# TODO password # TODO password
password= ... password= ...
# empty addresses - listn only on unix socket pgdata-directory = ${directory:srv}/postgresql
# empty addresses - listen only on unix socket
ipv4 = !py!set([]) ipv4 = !py!set([])
ipv6 = !py!set([]) ipv6 = !py!set([])
ipv6-random = ipv6-random =
port = port =
pgdata-directory = ${directory:srv}/postgresql
############# #############
# Redis # # Redis #
############# #############
[redis]
recipe = slapos.cookbook:mkdirectory
srv = ${directory:srv}/redis
[service-redis]
recipe = slapos.cookbook:redis.server
server_bin = {{ redis_bin }}
server_dir = ${redis:srv}
config_file = ${directory:etc}/redis.conf
log_file = ${directory:log}/redis.log
pid_file = ${directory:run}/redis.pid
use_passwd = false
wrapper = ${directory:service}/redis
promise_wrapper = ${directory:promise}/redis
unixsocket = ${:server_dir}/redis.socket
# port = 0 means "don't listen on TCP at all" - listen only on unix socket
ipv6 = ::1
port = 0
###################### ######################
# Nginx frontend # # Nginx frontend #
......
...@@ -35,6 +35,7 @@ context = ...@@ -35,6 +35,7 @@ context =
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 postgresql_location ${postgresql92:location}
raw redis_bin ${redis28:location}/bin/redis-server
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}
......
...@@ -8,6 +8,7 @@ production: ...@@ -8,6 +8,7 @@ production:
encoding: unicode encoding: unicode
database: {{ pgsql.dbname }} database: {{ pgsql.dbname }}
pool: 10 pool: 10
{# XXX is it ok to use superuser, even if the whole database is only for gitlab? #}
username: '{{ pgsql.superuser }}' username: '{{ pgsql.superuser }}'
password: password:
host: '{{ pgsql["pgdata-directory"] }}' host: '{{ pgsql["pgdata-directory"] }}'
......
...@@ -3,5 +3,4 @@ ...@@ -3,5 +3,4 @@
# 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: unix://{{ redis.unixsocket }}
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