add haproxy health checks option and tests
This commit is contained in:
parent
fab296e6dc
commit
eec5b5c24e
1 changed files with 19 additions and 8 deletions
|
@ -4,6 +4,8 @@
|
||||||
}:
|
}:
|
||||||
{ serviceName
|
{ serviceName
|
||||||
, servers ? []
|
, servers ? []
|
||||||
|
, httpcheck ? null
|
||||||
|
, balance ? null
|
||||||
, phpFastcgi ? false
|
, phpFastcgi ? false
|
||||||
, phpDocroot ? null
|
, phpDocroot ? null
|
||||||
, phpIndex ? "index.php"
|
, phpIndex ? "index.php"
|
||||||
|
@ -24,7 +26,12 @@ let
|
||||||
in
|
in
|
||||||
concatStringsSep " " ([
|
concatStringsSep " " ([
|
||||||
"server ${serviceName}${toString i} ${s.address}"
|
"server ${serviceName}${toString i} ${s.address}"
|
||||||
] ++ proto ++ s.extra);
|
]
|
||||||
|
++ proto
|
||||||
|
++ (optional (hasAttr "check" s && s.check != null) (
|
||||||
|
concatStrings (["check"] ++ (map (k: if !hasAttr k s.check then "" else " ${k} ${getAttr k s.check}") ["inter" "downinter" "fall" "rise"]))
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
serverslines = imap1 mkServer servers;
|
serverslines = imap1 mkServer servers;
|
||||||
|
|
||||||
|
@ -34,13 +41,17 @@ let
|
||||||
[
|
[
|
||||||
"backend ${serviceName}"
|
"backend ${serviceName}"
|
||||||
]
|
]
|
||||||
++ indent [
|
++ indent (
|
||||||
"mode http"
|
[
|
||||||
"option forwardfor"
|
"mode http"
|
||||||
]
|
"option forwardfor"
|
||||||
++ indent extraBackendOptions
|
]
|
||||||
++ optional phpFastcgi " use-fcgi-app ${serviceName}-php-fpm"
|
++ extraBackendOptions
|
||||||
++ indent serverslines
|
++ optional (balance != null) "balance ${balance}"
|
||||||
|
++ optional (httpcheck != null) "option httpchk ${httpcheck}"
|
||||||
|
++ optional phpFastcgi "use-fcgi-app ${serviceName}-php-fpm"
|
||||||
|
++ serverslines
|
||||||
|
)
|
||||||
++ [""]) # final newline
|
++ [""]) # final newline
|
||||||
) +
|
) +
|
||||||
(if !phpFastcgi then "" else ''
|
(if !phpFastcgi then "" else ''
|
||||||
|
|
Loading…
Add table
Reference in a new issue