File tree Expand file tree Collapse file tree 4 files changed +45
-1
lines changed
build-resources/geocml-task-scheduler/geocml-task-scheduler Expand file tree Collapse file tree 4 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 1+ from task_logger import log
2+ import bs4 as bs
3+ import os
4+ import requests
5+
6+ def register_with_drgon ():
7+ host = os .environ ["DRGON_HOST" ]
8+ api_key = os .environ ["DRGON_API_KEY" ]
9+
10+ if host == "" or api_key == "" :
11+ log ("Host or API key not found, can't register this deployment with DRGON." )
12+ return 0
13+
14+ res = requests .get ("http://geocml-server/cgi-bin/qgis_mapserv.fcgi?SERVICE=WFS&VERSION=1.3.0&REQUEST=GetCapabilities" )
15+ xml = bs .BeautifulSoup (res .text , "html.parser" )
16+ abstract = xml .find ("ows:abstract" , text = lambda text : isinstance (text , bs .CData )).string .strip ()
17+ title = xml .find ("ows:title" ).text
18+ url = "https://google.com" # TODO: make this dynamic
19+ owner = xml .find ("ows:individualname" ).text
20+ keywords = xml .find ("ows:keywords" ).find_all ("ows:keyword" )
21+ tags = ""
22+ for keyword in keywords :
23+ tags += f"{ keyword .text } ,"
24+ tags = tags [:- 1 ]
25+
26+ res = requests .post (f"{ host } /registry" , json = {
27+ "title" : title ,
28+ "description" : abstract ,
29+ "url" : url ,
30+ "owner" : owner ,
31+ "tags" : tags ,
32+ "key" : api_key
33+ })
34+
35+ if res .json ()["message" ] != "Done." :
36+ log (f"Failed to register deployment with DRGON: { res .json ()['message' ]} " )
Original file line number Diff line number Diff line change 11pyyaml
22psycopg2-binary
3+ bs4
4+ requests
Original file line number Diff line number Diff line change 22from backup_geocml_db import backup_geocml_db
33from restore_geocml_db_from_backups import restore_geocml_db_from_backups
44from healthcheck_services import healthcheck_services
5+ from register_with_drgon import register_with_drgon
56
67backup_geocml_db_task = Task (backup_geocml_db , (), 3600 ) # task runs every hour
78backup_geocml_db_task .start ()
1213healthcheck_services_task = Task (healthcheck_services , (), 60 )
1314healthcheck_services_task .start ()
1415
16+ register_with_drgon_task = Task (register_with_drgon , (), 60 )
17+ register_with_drgon_task .start ()
18+
1519while True :
1620 pass # keep schedule.py process running in container
Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ services:
88 image : ghcr.io/geocml/geocml-base-deployment:task-scheduler
99 hostname : geocml-task-scheduler
1010 environment :
11- - PATH=/geocml-task-scheduler/tabor/dist/tabor:$PATH
11+ PATH : /geocml-task-scheduler/tabor/dist/tabor:$PATH
12+ DRGON_API_KEY : ${DRGON_API_KEY}
13+ DRGON_HOST : ${DRGON_HOST}
1214 networks :
1315 - geocml-network
1416 volumes :
You can’t perform that action at this time.
0 commit comments