blob: 94df1bd6a8dbca9bf0f290d52b0c66a90b155009 [file] [log] [blame]
Baptiste Assmann71503d32015-09-18 16:38:21 +02001Reloading HAProxy without impacting server states
2=================================================
3
4Of course, to fully understand below information please consult
5doc/configuration.txt to understand how each HAProxy directive works.
6
7In the mean line, we update HAProxy's configuration to tell it where to
8retrieve the last know trustable servers state.
9Then, before reloading HAProxy, we simply dump servers state from running
10process into the locations we pointed into the configuration.
11And voilĂ  :)
12
13
14Using one file for all backends
15-------------------------------
16
17HAProxy configuration
18*********************
19
20 global
21 [...]
22 stats socket /var/run/haproxy/socket
23 server-state-file global
24 server-state-base /var/state/haproxy/
25
26 defaults
27 [...]
28 load-server-state-from-file global
29
30HAProxy init script
31*******************
32
33Run the following command BEFORE reloading:
34
35 socat /var/run/haproxy/socket - <<< "show servers state" > /var/state/haproxy/global
36
37
38Using one state file per backend
39--------------------------------
40
41HAProxy configuration
42*********************
43
44 global
45 [...]
46 stats socket /var/run/haproxy/socket
47 server-state-base /var/state/haproxy/
48
49 defaults
50 [...]
51 load-server-state-from-file local
52
53HAProxy init script
54*******************
55
56Run the following command BEFORE reloading:
57
58 for b in $(socat /var/run/haproxy/socket - <<< "show backend" | fgrep -v '#')
59 do
60 socat /var/run/haproxy/socket - <<< "show servers state $b" > /var/state/haproxy/$b
61 done
62