Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lukas Niegsch
slapos
Commits
dab618d1
Commit
dab618d1
authored
Oct 17, 2011
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add haproxy instanciation
parent
429b7c92
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
161 additions
and
43 deletions
+161
-43
slapos/recipe/erp5/__init__.py
slapos/recipe/erp5/__init__.py
+0
-41
slapos/recipe/haproxy/__init__.py
slapos/recipe/haproxy/__init__.py
+100
-0
slapos/recipe/haproxy/template/haproxy-server-snippet.cfg.in
slapos/recipe/haproxy/template/haproxy-server-snippet.cfg.in
+2
-0
slapos/recipe/haproxy/template/haproxy.cfg.in
slapos/recipe/haproxy/template/haproxy.cfg.in
+0
-0
software/erp5/instance-haproxy.cfg
software/erp5/instance-haproxy.cfg
+49
-0
software/erp5/instance.cfg
software/erp5/instance.cfg
+1
-1
software/erp5/software.cfg
software/erp5/software.cfg
+9
-1
No files found.
slapos/recipe/erp5/__init__.py
View file @
dab618d1
...
@@ -544,47 +544,6 @@ SSLCARevocationPath %(ca_crl)s"""
...
@@ -544,47 +544,6 @@ SSLCARevocationPath %(ca_crl)s"""
certificate_authority_path
=
config
[
'ca_dir'
]
certificate_authority_path
=
config
[
'ca_dir'
]
)
)
def
installHaproxy
(
self
,
ip
,
port
,
name
,
server_check_path
,
url_list
):
# inter must be quite short in order to detect quickly an unresponsive node
# and to detect quickly a node which is back
# rise must be minimal possible : 1, indeed, a node which is back don't need
# to sleep more time and we can give him work immediately
# fall should be quite sort. with inter at 3, and fall at 2, a node will be
# considered as dead after 6 seconds.
# maxconn should be set as the maximum thread we have per zope, like this
# haproxy will manage the queue of request with the possibility to
# move a request to another node if the initially selected one is dead
# maxqueue is the number of waiting request in the queue of every zope client.
# It allows to make sure that there is not a zope client handling all
# the work while other clients are doing nothing. This was happening
# even thoug we have round robin distribution because when a node dies
# some seconds, all request are dispatched to other nodes, and then users
# stick in other nodes and are not coming back. Please note this option
# is not an issue if you have more than (maxqueue * node_quantity) requests
# because haproxy will handle a top-level queue
server_template
=
""" server %(name)s %(address)s cookie %(name)s check inter 3s rise 1 fall 2 maxqueue 5 maxconn %(cluster_zope_thread_amount)s"""
config
=
dict
(
name
=
name
,
ip
=
ip
,
port
=
port
,
server_check_path
=
server_check_path
,)
i
=
1
server_list
=
[]
cluster_zope_thread_amount
=
self
.
options
.
get
(
'cluster_zope_thread_amount'
,
1
)
for
url
in
url_list
:
server_list
.
append
(
server_template
%
dict
(
name
=
'%s_%s'
%
(
name
,
i
),
address
=
url
,
cluster_zope_thread_amount
=
cluster_zope_thread_amount
))
i
+=
1
config
[
'server_text'
]
=
'
\
n
'
.
join
(
server_list
)
haproxy_conf_path
=
self
.
createConfigurationFile
(
'haproxy_%s.cfg'
%
name
,
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'haproxy.cfg.in'
),
config
))
self
.
path_list
.
append
(
haproxy_conf_path
)
wrapper
=
zc
.
buildout
.
easy_install
.
scripts
([(
'haproxy_%s'
%
name
,
'slapos.recipe.librecipe.execute'
,
'execute'
)],
self
.
ws
,
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
self
.
options
[
'haproxy_binary'
].
strip
(),
'-f'
,
haproxy_conf_path
]
)[
0
]
self
.
path_list
.
append
(
wrapper
)
return
'%s:%s'
%
(
ip
,
port
)
def
installERP5
(
self
):
def
installERP5
(
self
):
"""
"""
All zope have to share file created by portal_classes
All zope have to share file created by portal_classes
...
...
slapos/recipe/haproxy/__init__.py
0 → 100644
View file @
dab618d1
##############################################################################
#
# Copyright (c) 2011 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
slapos.recipe.librecipe
import
GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
"""
haproxy instance configuration.
name -- local name of the haproxy
wrapper-path -- location of the init script to generate
binary-path -- location of the haproxy command
conf-path -- location of the configuration file
ip -- ip of the haproxy server
port -- port of the haproxy server
server-check-path -- path of the domain to check
address -- string with list of all url to check
Example: 127.0.0.1:12004 127.0.0.1:12005
"""
def
install
(
self
):
# inter must be quite short in order to detect quickly an unresponsive node
# and to detect quickly a node which is back
# rise must be minimal possible : 1, indeed, a node which is back don't need
# to sleep more time and we can give him work immediately
# fall should be quite sort. with inter at 3, and fall at 2, a node will be
# considered as dead after 6 seconds.
# maxconn should be set as the maximum thread we have per zope, like this
# haproxy will manage the queue of request with the possibility to
# move a request to another node if the initially selected one is dead
# maxqueue is the number of waiting request in the queue of every zope client.
# It allows to make sure that there is not a zope client handling all
# the work while other clients are doing nothing. This was happening
# even thoug we have round robin distribution because when a node dies
# some seconds, all request are dispatched to other nodes, and then users
# stick in other nodes and are not coming back. Please note this option
# is not an issue if you have more than (maxqueue * node_quantity) requests
# because haproxy will handle a top-level queue
snippet_filename
=
self
.
getTemplateFilename
(
'haproxy-server-snippet.cfg.in'
)
# Prepare all filestorages
server_snippet
=
""
i
=
0
for
address
in
self
.
options
[
'address'
].
split
():
i
+=
1
server_snippet
+=
self
.
substituteTemplate
(
snippet_filename
,
dict
(
name
=
'%s_%s'
%
(
name
,
i
),
address
=
address
,
cluster_zope_thread_amount
=
self
.
options
[
'maxconn'
]))
config
=
dict
(
name
=
name
,
ip
=
self
.
options
[
'ip'
],
port
=
self
.
options
[
'port'
],
server_text
=
server_snippet
,
server_check_path
=
server_check_path
,)
template_filename
=
self
.
getTemplateFilename
(
'haproxy.cfg.in'
)
configuration_path
=
self
.
createFile
(
self
.
options
[
'conf-path'
],
self
.
substituteTemplate
(
template_filename
,
config
))
# Create running wrapper
wrapper_path
=
self
.
createPythonScript
(
self
.
options
[
'wrapper-path'
],
'slapos.recipe.librecipe.execute.execute'
,
arguments
=
[
self
.
options
[
'binary-path'
].
strip
(),
'-f'
,
configuration_path
],
return
[
configuration_path
,
wrapper_path
]
slapos/recipe/haproxy/template/haproxy-server-snippet.cfg.in
0 → 100644
View file @
dab618d1
server %(name)s %(address)s cookie %(name)s check inter 3s rise 1 fall 2 maxqueue 5 maxconn %(cluster_zope_thread_amount)s
slapos/recipe/
erp5
/template/haproxy.cfg.in
→
slapos/recipe/
haproxy
/template/haproxy.cfg.in
View file @
dab618d1
File moved
software/erp5/instance-haproxy.cfg
View file @
dab618d1
#############################
#
# Instanciate haproxy
#
# haproxy-id -- local id of the requested haproxy (login, web,...)
#
# haproxy-port -- ip port to use to run the process
#
# maxconn -- max connection per server
#
# site-id -- ID of the ERP5 site object in ZODB
#
# storage_list -- string with list of all resquested storage
# Example: event_module person_module
#
#############################
[buildout]
parts =
haproxy-instance
publish-haproxy-connection-information
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
[basedirectory]
recipe = slapos.cookbook:mkdirectory
services = $${rootdirectory:etc}/run/
[haproxy-instance]
recipe = slapos.cookbook:haproxy
name = $${slap-parameter:haproxy-id}
conf-path = $${rootdirectory:etc}/haproxy-$${slap-parameter:haproxy-id}.cfg
ip = $${slap-network-information:local-ipv4}
port = $${slap-parameter:haproxy-port}
maxconn = $${slap-parameter:maxconn}
server-check-path = /$${slap-parameter:site-id}/getId
wrapper-path = $${basedirectory:services}/haproxy_$${slap-parameter:haproxy-id}
binary-path = ${memcached:location}/bin/memcached
[publish-memcached-connection-information]
recipe = slapos.cookbook:publishurl
url = http://$${haproxy-instance:ip}:$${haproxy-instance:port}/
software/erp5/instance.cfg
View file @
dab618d1
...
@@ -8,7 +8,6 @@ develop-eggs-directory = ${buildout:develop-eggs-directory}
...
@@ -8,7 +8,6 @@ develop-eggs-directory = ${buildout:develop-eggs-directory}
[instance]
[instance]
recipe = ${instance-recipe:egg}:${instance-recipe:module}
recipe = ${instance-recipe:egg}:${instance-recipe:module}
dcrond_binary = ${dcron:location}/sbin/crond
dcrond_binary = ${dcron:location}/sbin/crond
haproxy_binary = ${haproxy:location}/sbin/haproxy
gzip_binary = ${gzip:location}/bin/gzip
gzip_binary = ${gzip:location}/bin/gzip
httpd_binary = ${apache:location}/bin/httpd
httpd_binary = ${apache:location}/bin/httpd
innobackupex_binary = ${xtrabackup:location}/bin/innobackupex
innobackupex_binary = ${xtrabackup:location}/bin/innobackupex
...
@@ -88,3 +87,4 @@ cloudooo = ${template-cloudooo:output}
...
@@ -88,3 +87,4 @@ cloudooo = ${template-cloudooo:output}
zope = ${template-zope:output}
zope = ${template-zope:output}
zeo = ${template-zeo:output}
zeo = ${template-zeo:output}
mariadb = ${template-mariadb:output}
mariadb = ${template-mariadb:output}
haproxy = ${template-haproxy:output}
software/erp5/software.cfg
View file @
dab618d1
...
@@ -13,6 +13,7 @@ parts +=
...
@@ -13,6 +13,7 @@ parts +=
template-cloudooo
template-cloudooo
template-zope
template-zope
template-mariadb
template-mariadb
template-haproxy
template
template
validator
validator
...
@@ -49,6 +50,13 @@ md5sum = e5db0a46a9ec3661ff9da2d5fcaf9d9a
...
@@ -49,6 +50,13 @@ md5sum = e5db0a46a9ec3661ff9da2d5fcaf9d9a
output = ${buildout:directory}/template-kumofs.cfg
output = ${buildout:directory}/template-kumofs.cfg
mode = 0644
mode = 0644
[template-haproxy]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-haproxy.cfg
md5sum = d7f957798d55afff3ba7088d623e6d00
output = ${buildout:directory}/template-haproxy.cfg
mode = 0644
[instance-recipe]
[instance-recipe]
# Note: In case if specific instantiation recipe is used this is the place to
# Note: In case if specific instantiation recipe is used this is the place to
# put its name
# put its name
...
@@ -61,7 +69,7 @@ configurator_bt5_list = erp5_core_proxy_field_legacy erp5_full_text_myisam_catal
...
@@ -61,7 +69,7 @@ configurator_bt5_list = erp5_core_proxy_field_legacy erp5_full_text_myisam_catal
[template]
[template]
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
url = ${:_profile_base_location_}/instance.cfg
md5sum =
f575d9f5e47fd340cf99bd63db15ac36
md5sum =
84df9e6c726934c49e84d0cb274e28dc
output = ${buildout:directory}/template.cfg
output = ${buildout:directory}/template.cfg
mode = 0644
mode = 0644
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment