1
0
mirror of https://github.com/Luzifer/dns.git synced 2024-09-19 15:23:03 +00:00

Move healthcheck to python script

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-12-15 01:47:22 +01:00
parent c28c273d7a
commit 21ffa283ef
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E
2 changed files with 9 additions and 3 deletions

View File

@ -15,6 +15,7 @@ import consul
import dns.resolver import dns.resolver
import dns.rdatatype import dns.rdatatype
import jinja2 import jinja2
import requests
import yaml import yaml
DEFAULT_TTL = 3600 DEFAULT_TTL = 3600
@ -131,6 +132,11 @@ def write_zone(zone, ttl, soa, nameserver, mailserver, entries):
os.unlink("zones/tmp.{}".format(zone)) os.unlink("zones/tmp.{}".format(zone))
def healthcheck():
if os.getenv('HC_PING') != '':
requests.get(os.getenv('HC_PING'))
def main(): def main():
zone_data = yaml.load(open("zones.yml")) zone_data = yaml.load(open("zones.yml"))
@ -155,6 +161,8 @@ def main():
write_zone(zone, ttl, zone_data['soa'], write_zone(zone, ttl, zone_data['soa'],
zone_data['nameserver'], mailserver, entries) zone_data['nameserver'], mailserver, entries)
healthcheck()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -2,6 +2,4 @@
set -euxo pipefail set -euxo pipefail
cd /src cd /src
/usr/bin/python3 generateZonefiles.py exec /usr/bin/python3 generateZonefiles.py
[ -n "${HC_PING}" ] && curl -sSfLo /dev/null "${HC_PING}"