mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-22 14:32:15 +00:00
host_manager, cron
This commit is contained in:
@@ -131,6 +131,7 @@ def upload_certificates(c):
|
|||||||
|
|
||||||
def debug_tmp(c):
|
def debug_tmp(c):
|
||||||
upload_https_host_files(c)
|
upload_https_host_files(c)
|
||||||
|
put(c, SCRIPTS_DIR / 'http_host' / 'cron.d' / 'ofm_http_host', '/etc/cron.d/')
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
PYTHON=/data/ofm/venv/bin/python
|
# every minute sync, locking so that only one process can run at a time
|
||||||
BIN=/data/ofm/http_host/bin
|
* * * * * ofm /usr/bin/flock -n /tmp/hostmanager.lockfile -c \
|
||||||
|
'sudo /data/ofm/venv/bin/python -u /data/ofm/http_host/bin/host_manager.py sync >> /data/ofm/http_host/logs/host_manager_sync.log 2>&1'
|
||||||
|
|
||||||
|
|
||||||
# every minute sync
|
|
||||||
* * * * * ofm sudo $PYTHON -u $BIN/host_manager.py sync >> /data/ofm/http_host/logs/host_manager_sync.log 2>&1
|
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ def download_and_extract_tileset(area: str, version: str, runs_dir: Path) -> boo
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
temp_dir = runs_dir / '_tmp'
|
temp_dir = runs_dir / '_tmp'
|
||||||
if temp_dir.exists():
|
shutil.rmtree(temp_dir, ignore_errors=True)
|
||||||
sys.exit(f'{temp_dir} dir exists, avoiding parallel run')
|
|
||||||
|
|
||||||
temp_dir.mkdir(parents=True)
|
temp_dir.mkdir(parents=True)
|
||||||
|
|
||||||
url = f'https://{area}.openfreemap.com/{version}/tiles.btrfs.gz'
|
url = f'https://{area}.openfreemap.com/{version}/tiles.btrfs.gz'
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ def write_nginx_config():
|
|||||||
f'curl -I https://tiles.openfreemap.org/{area}/{version}/14/8529/5975.pbf'
|
f'curl -I https://tiles.openfreemap.org/{area}/{version}/14/8529/5975.pbf'
|
||||||
)
|
)
|
||||||
|
|
||||||
location_str += create_deployed_location(area, version, subdir)
|
for area in ['monaco', 'planet']:
|
||||||
|
location_str += create_latest_location(area)
|
||||||
|
|
||||||
nginx_template = nginx_template.replace('___LOCATION_BLOCKS___', location_str)
|
nginx_template = nginx_template.replace('___LOCATION_BLOCKS___', location_str)
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ def write_nginx_config():
|
|||||||
print(curl_text)
|
print(curl_text)
|
||||||
|
|
||||||
|
|
||||||
def create_version_location(area: str, version: str, subdir: Path):
|
def create_version_location(area: str, version: str, subdir: Path) -> str:
|
||||||
run_dir = DEFAULT_RUNS_DIR / area / version
|
run_dir = DEFAULT_RUNS_DIR / area / version
|
||||||
if not run_dir.is_dir():
|
if not run_dir.is_dir():
|
||||||
print(f" {run_dir} doesn't exists, skipping")
|
print(f" {run_dir} doesn't exists, skipping")
|
||||||
@@ -91,5 +92,13 @@ def create_version_location(area: str, version: str, subdir: Path):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def create_deployed_location(area: str, version: str, subdir: Path):
|
def create_latest_location(area: str) -> str:
|
||||||
pass
|
local_version_file = Path(f'/data/ofm/config/deployed_tiles_{area}.txt')
|
||||||
|
|
||||||
|
if not local_version_file.exists():
|
||||||
|
return ''
|
||||||
|
|
||||||
|
with open(local_version_file) as fp:
|
||||||
|
version_str = fp.read().strip()
|
||||||
|
|
||||||
|
print(version_str)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ def pkg_base(c):
|
|||||||
'unzip',
|
'unzip',
|
||||||
'wget',
|
'wget',
|
||||||
'psmisc',
|
'psmisc',
|
||||||
|
'util-linux'
|
||||||
#
|
#
|
||||||
'btrfs-progs',
|
'btrfs-progs',
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user