DOC: load-server-state-from-file
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 4d6676f..671a4c2 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -763,7 +763,8 @@
server-state-base <directory>
Specifies the directory prefix to be prepended in front of all servers state
- file names which do not start with a '/'. See also "server-state-file".
+ file names which do not start with a '/'. See also "server-state-file",
+ "load-server-state-from-file" and "server-state-file-name".
server-state-file <file>
Specifies the path to the file containing state of servers. If the path starts
@@ -774,7 +775,8 @@
output of this command must be written in the file pointed by <file>. When
starting up, before handling traffic, HAProxy will read, load and apply state
for each server found in the file and available in its current running
- configuration. See also "server-state-base" and "show servers state".
+ configuration. See also "server-state-base" and "show servers state",
+ "load-server-state-from-file" and "server-state-file-name"
ssl-default-bind-ciphers <ciphers>
This setting is only available when support for OpenSSL was built in. It sets
@@ -1642,6 +1644,7 @@
http-send-name-header - - X X
id - X X X
ignore-persist - X X X
+load-server-state-from-file X - X X
log (*) X X X X
log-format X X X -
log-tag X X X X
@@ -1732,6 +1735,7 @@
rspirep - X X X
rsprep - X X X
server - - X X
+server-state-file-name X - X X
source X - X X
srvtimeout (deprecated) X - X X
stats admin - - X X
@@ -4145,6 +4149,97 @@
See also : "force-persist", "cookie", and section 7 about ACL usage.
+load-server-state-from-file { global | local | none }
+ Allow seamless reload of HAProxy
+ May be used in sections: defaults | frontend | listen | backend
+ yes | no | yes | yes
+
+ This directive points HAProxy to a file where server state from previous
+ running process has been saved. That way, when starting up, before handling
+ traffic, the new process can apply old states to servers exactly has if no
+ reload occured. The purpose of the "load-server-state-from-file" directive is
+ to tell haproxy which file to use. For now, only 2 arguments to either prevent
+ loading state or load states from a file containing all backends and servers.
+ The state file can be generated by running the command "show servers state"
+ over the stats socket and redirect output.
+
+ The format of the file is versionned and is very specific. To understand it,
+ please read the documentation of the "show servers state" command (chapter
+ 9.2).
+
+ Arguments:
+ global load the content of the file pointed by the global directive
+ named "server-state-file".
+
+ local load the content of the file pointed by the directive
+ "server-state-file-name" if set. If not set, then the backend
+ name is used as a file name.
+
+ none don't load any stat for this backend
+
+ Notes:
+ - server's IP address is not updated unless DNS resolution is enabled on
+ the server. It means that if a server IP address has been changed using
+ the stat socket, this information won't be re-applied after reloading.
+
+ - server's weight is applied from previous running process unless it has
+ has changed between previous and new configuration files.
+
+ Example 1:
+
+ Minimal configuration:
+
+ global
+ stats socket /tmp/socket
+ server-state-file /tmp/server_state
+
+ defaults
+ load-server-state-from-file global
+
+ backend bk
+ server s1 127.0.0.1:22 check weight 11
+ server s2 127.0.0.1:22 check weight 12
+
+ Then one can run :
+
+ socat /tmp/socket - <<< "show servers state" > /tmp/server_state
+
+ Content of the file /tmp/server_state would be like this:
+
+ 1
+ # <field names skipped for the doc example>
+ 1 bk 1 s1 127.0.0.1 2 0 11 11 4 6 3 4 6 0 0
+ 1 bk 2 s2 127.0.0.1 2 0 12 12 4 6 3 4 6 0 0
+
+ Example 2:
+
+ Minimal configuration:
+
+ global
+ stats socket /tmp/socket
+ server-state-base /etc/haproxy/states
+
+ defaults
+ load-server-state-from-file local
+
+ backend bk
+ server s1 127.0.0.1:22 check weight 11
+ server s2 127.0.0.1:22 check weight 12
+
+ Then one can run :
+
+ socat /tmp/socket - <<< "show servers state bk" > /etc/haproxy/states/bk
+
+ Content of the file /etc/haproxy/states/bk would be like this:
+
+ 1
+ # <field names skipped for the doc example>
+ 1 bk 1 s1 127.0.0.1 2 0 11 11 4 6 3 4 6 0 0
+ 1 bk 2 s2 127.0.0.1 2 0 12 12 4 6 3 4 6 0 0
+
+ See also: "server-state-file", "server-state-file-name", and
+ "show servers state"
+
log global
log <address> [len <length>] <facility> [<level> [<minlevel>]]
@@ -6896,6 +6991,25 @@
See also: "default-server", "http-send-name-header" and section 5 about
server options
+server-state-file-name [<file>]
+ Set the server state file to read, load and apply to servers available in
+ this backend. It only applies when the directive "load-server-state-from-file"
+ is set to "local". When <file> is not provided or if this directive is not
+ set, then backend name is used. If <file> starts with a slash '/', then it is
+ considered as an absolute path. Otherwise, <file> is concatenated to the
+ global directive "server-state-file-base".
+
+ Example: the minimal configuration below would make HAProxy look for the
+ state server file '/etc/haproxy/states/bk':
+
+ global
+ server-state-file-base /etc/haproxy/states
+
+ backend bk
+ load-server-state-from-file
+
+ See also: "server-state-file-base", "load-server-state-from-file", and
+ "show servers state"
source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | hdr_ip(<hdr>[,<occ>]) } ]