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
Xavier Thompson
slapos
Commits
7984b871
Commit
7984b871
authored
Sep 27, 2012
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
haproxy supports more than one listening port. Support it in recipe too.
parent
037ef82c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
36 deletions
+45
-36
slapos/recipe/haproxy/__init__.py
slapos/recipe/haproxy/__init__.py
+39
-26
slapos/recipe/haproxy/template/haproxy-listen-snippet.cfg.in
slapos/recipe/haproxy/template/haproxy-listen-snippet.cfg.in
+6
-0
slapos/recipe/haproxy/template/haproxy-server-snippet.cfg.in
slapos/recipe/haproxy/template/haproxy-server-snippet.cfg.in
+0
-1
slapos/recipe/haproxy/template/haproxy.cfg.in
slapos/recipe/haproxy/template/haproxy.cfg.in
+0
-9
No files found.
slapos/recipe/haproxy/__init__.py
View file @
7984b871
...
...
@@ -66,40 +66,53 @@ class Recipe(GenericBaseRecipe):
# 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
name
=
self
.
options
[
'name'
]
try
:
backend_dict
=
self
.
options
[
'backend-dict'
]
except
KeyError
:
backend_list
=
self
.
options
[
'backend-list'
]
if
isinstance
(
backend_list
,
str
):
# BBB
backend_list
=
backend_list
.
split
()
backend_dict
=
{
self
.
options
[
'name'
]:
(
self
.
options
[
'port'
],
backend_list
),
}
server_snippet_filename
=
self
.
getTemplateFilename
(
'haproxy-server-snippet.cfg.in'
)
listen_snippet_filename
=
self
.
getTemplateFilename
(
'haproxy-listen-snippet.cfg.in'
)
server_snippet
=
""
ip
=
self
.
options
[
'ip'
]
server_check_path
=
self
.
options
[
'server-check-path'
]
# FIXME: maxconn must be provided per-backend, not globally
maxconn
=
self
.
options
[
'maxconn'
]
i
=
0
for
name
,
(
port
,
backend_list
)
in
backend_dict
.
iteritems
():
server_snippet
+=
self
.
substituteTemplate
(
listen_snippet_filename
,
{
'name'
:
name
,
'ip'
:
ip
,
'port'
:
port
,
'server_check_path'
:
server_check_path
,
})
for
address
in
backend_list
:
i
+=
1
server_snippet
+=
self
.
substituteTemplate
(
snippet_filename
,
dict
(
name
=
'%s_%s'
%
(
name
,
i
),
address
=
address
,
cluster_zope_thread_amount
=
self
.
options
[
'maxconn'
]))
server_snippet_filename
,
{
'name'
:
'%s_%s'
%
(
name
,
i
),
'address'
:
address
,
'cluster_zope_thread_amount'
:
maxconn
,
})
config
=
dict
(
name
=
name
,
ip
=
self
.
options
[
'ip'
],
port
=
self
.
options
[
'port'
],
server_text
=
server_snippet
,
server_check_path
=
self
.
options
[
'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
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'haproxy.cfg.in'
),
{
'server_text'
:
server_snippet
},
)
)
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-listen-snippet.cfg.in
0 → 100644
View file @
7984b871
listen %(name)s %(ip)s:%(port)s
cookie SERVERID insert
balance roundrobin
option httpchk GET %(server_check_path)s
stats uri /haproxy
stats realm Global\ statistics
slapos/recipe/haproxy/template/haproxy-server-snippet.cfg.in
View file @
7984b871
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/haproxy/template/haproxy.cfg.in
View file @
7984b871
...
...
@@ -29,13 +29,4 @@ defaults
# to render a page
option forceclose
listen %(name)s %(ip)s:%(port)s
cookie SERVERID insert
balance roundrobin
%(server_text)s
option httpchk GET %(server_check_path)s
stats uri /haproxy
stats realm Global\ statistics
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