configuration-templates – Blame information for rev 171
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
171 | office | 1 | #!/bin/bash |
2 | ########################################################################### |
||
3 | ## Copyright (C) Wizardry and Steamworks 2023 - License: GNU GPLv3 ## |
||
4 | ########################################################################### |
||
5 | # This script matches the PID reported by HAproxy via its internal stats # |
||
6 | # interface to the PID of the process from the process table and iff. the # |
||
7 | # two match then the script returns 0. # |
||
8 | # # |
||
9 | # Requirements: # |
||
10 | # * socket # |
||
11 | # # |
||
12 | ########################################################################### |
||
13 | |||
14 | ########################################################################### |
||
15 | # CONFIGURATION # |
||
16 | ########################################################################### |
||
17 | |||
18 | # HAProxy needs the socket for stats to be exposed. |
||
19 | # These settings added to the global section should enable the socket: |
||
20 | # stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners |
||
21 | # stats timeout 30s |
||
22 | SOCKET_PATH="/run/haproxy/admin.sock" |
||
23 | PID_FILE="/run/haproxy.pid" |
||
24 | |||
25 | ########################################################################### |
||
26 | # INTERNALS # |
||
27 | ########################################################################### |
||
28 | |||
29 | PID=$(cat <<EOF | \ |
||
30 | socat "$SOCKET_PATH" stdio | \ |
||
31 | grep ^Pid | \ |
||
32 | awk -F': ' '{ print $2 }' |
||
33 | show info |
||
34 | EOF |
||
35 | ) |
||
36 | |||
37 | [ "$PID" != `cat "$PID_FILE"` ] || exit 1 |
||
38 | |||
39 | exit 0 |