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