Commit ec01997c authored by Kirill Smelkov's avatar Kirill Smelkov

X on embedded redis

parent 80442a6c
......@@ -45,6 +45,11 @@ class Recipe(GenericBaseRecipe):
log_file=self.options['log_file'],
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,
self.substituteTemplate(self.getTemplateFilename('redis.conf.in'),
......@@ -63,7 +68,8 @@ class Recipe(GenericBaseRecipe):
promise = self.createPythonScript(
promise_script,
'%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)
......
......@@ -7,12 +7,14 @@ import sys
def main(args):
host = args['host']
port = int(args['port'])
unixsocket = args['unixsocket']
try:
pool = redis.ConnectionPool(host=host, port=port, db=0)
r = redis.Redis(connection_pool=pool)
#pool = redis.ConnectionPool(host=host, port=port, unix_socket_path=unixsocket, db=0)
#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")
pool.disconnect()
r.connection_pool.disconnect()
sys.exit(0)
except Exception, e:
print str(e)
sys.exit(1)
\ No newline at end of file
sys.exit(1)
......@@ -72,9 +72,7 @@ bind %(ipv6)s
# 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
# on a unix socket when not specified.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 700
%(unixsocket)s
# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
......
......@@ -18,7 +18,7 @@ parts =
service-nginx
service-postgresql
# service-redis
service-redis
# std stuff for slapos instance
......@@ -69,38 +69,6 @@ recipe = slapos.cookbook:publish
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 #
......@@ -178,8 +146,8 @@ context =
[resque.yml]
<= gitlab-etc-template
template= {{ resque_yml_in }}
#context =
# section redis request-redis
context =
section redis service-redis
[smtp_settings.rb]
<= gitlab-etc-template
......@@ -338,7 +306,7 @@ command =
#recipe = slapos.cookbook:mkdirectory
#srv = ${directory:srv}/postgresql
# XXX etc - no
# XXX log
# XXX log - goes to stdout/stderr
[postgresql-password]
recipe = slapos.cookbook:generate.password
......@@ -361,20 +329,46 @@ superuser = gitlab
# TODO password
password= ...
# empty addresses - listn only on unix socket
pgdata-directory = ${directory:srv}/postgresql
# empty addresses - listen only on unix socket
ipv4 = !py!set([])
ipv6 = !py!set([])
ipv6-random =
port =
pgdata-directory = ${directory:srv}/postgresql
#############
# 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 #
......
......@@ -35,6 +35,7 @@ context =
raw nginx_bin ${nginx-output:nginx}
raw mime_types ${nginx-output:mime}
raw postgresql_location ${postgresql92:location}
raw redis_bin ${redis28:location}/bin/redis-server
raw macrolib_cfg_in ${macrolib.cfg.in:target}
raw gitlab_parameters_cfg ${gitlab-parameters.cfg:target}
......
......@@ -8,6 +8,7 @@ production:
encoding: unicode
database: {{ pgsql.dbname }}
pool: 10
{# XXX is it ok to use superuser, even if the whole database is only for gitlab? #}
username: '{{ pgsql.superuser }}'
password:
host: '{{ pgsql["pgdata-directory"] }}'
......
......@@ -3,5 +3,4 @@
# 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
{# production: redis://[{{ redis['connection-redis_ip'] }}]:{{ redis['connection-redis_port'] }} #}
production: redis://127.0.0.1:12345
production: unix://{{ redis.unixsocket }}
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