Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 8169660

Browse files
author
Feng Honglin
authored
Merge pull request #98 from dial-once/feature/nbproc
Handle NBPROC optional global setting using env vars
2 parents 1a88914 + 8935341 commit 8169660

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ ENV RSYSLOG_DESTINATION=127.0.0.1 \
2222
STATS_AUTH="stats:stats" \
2323
SSL_BIND_OPTIONS=no-sslv3 \
2424
SSL_BIND_CIPHERS="ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA:DES-CBC3-SHA" \
25-
HEALTH_CHECK="check inter 2000 rise 2 fall 3"
25+
HEALTH_CHECK="check inter 2000 rise 2 fall 3" \
26+
NBPROC=1
2627

2728
EXPOSE 80 443 1936
2829
ENTRYPOINT ["/sbin/tini", "--"]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ Settings in this part is immutable, you have to redeploy HAProxy service to make
196196
|STATS_AUTH|stats:stats|username and password required to access the Haproxy stats.|
197197
|STATS_PORT|1936|port for the HAProxy stats section. If this port is published, stats can be accessed at `http://<host-ip>:<STATS_PORT>/`
198198
|TIMEOUT|connect 5000, client 50000, server 50000|comma-separated list of HAProxy `timeout` entries to the `default` section.|
199+
|NBPROC|1|sets the `nbproc` entry to the `global` section. By default, only one process is created, which is the recommended mode of operation.|
199200

200201
### Settings in linked application services###
201202

haproxy/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def parse_extra_frontend_settings(envvars):
6060
STATS_AUTH = os.getenv("STATS_AUTH", "stats:stats")
6161
STATS_PORT = os.getenv("STATS_PORT", "1936")
6262
TIMEOUT = os.getenv("TIMEOUT", "connect 5000, client 50000, server 50000")
63+
NBPROC = int(os.getenv("NBPROC", 1))
6364

6465
# global
6566
LINK_MODE = ""

haproxy/haproxycfg.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ def _config_global_section():
195195
"daemon",
196196
"stats socket /var/run/haproxy.stats level admin"]
197197

198+
if NBPROC > 1:
199+
statements.append("nbproc %s" % NBPROC)
200+
statements.append("stats bind-process %s" % NBPROC)
201+
for x in range(1, NBPROC+1):
202+
statements.append("cpu-map %s %s" % (x, x-1))
203+
198204
statements.extend(ConfigHelper.config_ssl_bind_options(SSL_BIND_OPTIONS))
199205
statements.extend(ConfigHelper.config_ssl_bind_ciphers(SSL_BIND_CIPHERS))
200206
statements.extend(ConfigHelper.config_extra_settings(EXTRA_GLOBAL_SETTINGS))

0 commit comments

Comments
 (0)