65087da9b90d59121c86406ce3b451171ca80365
internal/Anycast-Wiki.md
... | ... | @@ -102,7 +102,7 @@ group gollum-watchdog { |
102 | 102 | ## ... |
103 | 103 | |
104 | 104 | process watch-gollum { |
105 | - run /etc/exabgp/gollum-watchdog.sh; |
|
105 | + run <path>/gollum-watchdog.sh; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
... | ... | @@ -113,11 +113,19 @@ group gollum-watchdog { |
113 | 113 | ``` |
114 | 114 | #!/bin/bash |
115 | 115 | |
116 | +CURL=curl |
|
117 | + |
|
118 | +## url's to check (all listed must be alive to send announce) |
|
116 | 119 | URL=( "http://172.23.0.80" "https://172.23.0.80" ) |
117 | 120 | |
118 | -VALIDATE_KEYWORD='gollum' |
|
121 | +## the anycast route (/28 due to prefix size limits) |
|
119 | 122 | ROUTE='172.23.0.80/28' |
120 | -NEXTHOP='172.22.177.72' |
|
123 | + |
|
124 | +## the next-hop we'll be advertising to neighbor(s) |
|
125 | +NEXTHOP='<source-address>' |
|
126 | + |
|
127 | +## regex match this keyword against HTTP response from curl |
|
128 | +VALIDATE_KEYWORD='gollum' |
|
121 | 129 | |
122 | 130 | INTERVAL=60 |
123 | 131 | |
... | ... | @@ -127,9 +135,16 @@ RUN_STATE=0 |
127 | 135 | |
128 | 136 | check_urls() { |
129 | 137 | for url in "${URL[@]}"; do |
130 | - curl --insecure -L -o - ${url} | egrep -q "${VALIDATE_KEYWORD}" || { |
|
138 | + |
|
139 | + ## workaround curl errno 23 when piping |
|
140 | + http_response=`${CURL} --insecure -L -o - "${url}"` |
|
141 | + |
|
142 | + echo "${http_response}" | egrep -q "${VALIDATE_KEYWORD}" || { |
|
131 | 143 | return 1 |
132 | 144 | } |
145 | + |
|
146 | + ## add more checks |
|
147 | + |
|
133 | 148 | done |
134 | 149 | return 0 |
135 | 150 | } |
... | ... | @@ -156,3 +171,57 @@ exit 0 |
156 | 171 | |
157 | 172 | ``` |
158 | 173 | |
174 | + Normally SIGUSR1 to the exabgp process triggers a configuration update, but at occasion the process might need to be restarted - since the gracefull shutdown might not always kick in , this might present quite a challenge. Sending SIGKILL to the child(ren) and immediately after, the parent, does the job (quick-and-dirty). |
|
175 | + |
|
176 | +#####/etc/exabgp/run.sh |
|
177 | + |
|
178 | +``` |
|
179 | + |
|
180 | +#!/bin/bash |
|
181 | + |
|
182 | +PID_FILE=/var/run/exaBGP/exabgp_PID |
|
183 | + |
|
184 | +###################################### |
|
185 | + |
|
186 | +EXABGP=<path>/sbin/exabgp |
|
187 | +EXA_LOG=/var/log/exabgp.log |
|
188 | +CONF=/etc/exabgp/exabgp.conf |
|
189 | + |
|
190 | + |
|
191 | +start() { |
|
192 | + [ -f ${PID_FILE} ] && { |
|
193 | + echo "WARNING: `cat ${PID_FILE}`: exabgp already running"; return 1 |
|
194 | + } |
|
195 | + ${EXABGP} ${CONF} &> ${EXA_LOG} & |
|
196 | + cpid=$! |
|
197 | + [ ${cpid} -eq 0 ] && { |
|
198 | + echo "ERROR: could not start process"; return 1 |
|
199 | + |
|
200 | + } |
|
201 | + echo $! > ${PID_FILE} |
|
202 | +} |
|
203 | + |
|
204 | +stop(){ |
|
205 | + [ -f ${PID_FILE} ] || return 1 |
|
206 | + pkill -9 -P $(cat ${PID_FILE}) |
|
207 | + kill -9 $(cat ${PID_FILE}) |
|
208 | + rm -f ${PID_FILE} |
|
209 | +} |
|
210 | + |
|
211 | +case ${1} in |
|
212 | + start ) |
|
213 | + start |
|
214 | + ;; |
|
215 | + stop ) |
|
216 | + stop |
|
217 | + ;; |
|
218 | + restart ) |
|
219 | + stop |
|
220 | + sleep 1 |
|
221 | + start |
|
222 | + ;; |
|
223 | +esac |
|
224 | + |
|
225 | +exit 0 |
|
226 | + |
|
227 | +``` |
|
... | ... | \ No newline at end of file |