mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
work
This commit is contained in:
@@ -165,7 +165,7 @@ Auto-update works!
|
|||||||
|
|
||||||
Monaco is generated every hour, set-latest runs every minute.
|
Monaco is generated every hour, set-latest runs every minute.
|
||||||
|
|
||||||
Planet is generated every Tuesday, set-latest runs every Saturday.
|
Planet is generated every Wednesday, set-latest runs every Saturday.
|
||||||
|
|
||||||
##### v0.3
|
##### v0.3
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from http_host_lib.btrfs import (
|
|||||||
download_area_version,
|
download_area_version,
|
||||||
get_versions_for_area,
|
get_versions_for_area,
|
||||||
)
|
)
|
||||||
from http_host_lib.mount import auto_mount_unmount
|
from http_host_lib.mount import auto_mount
|
||||||
from http_host_lib.nginx import write_nginx_config
|
from http_host_lib.nginx import write_nginx_config
|
||||||
from http_host_lib.sync import auto_clean_btrfs, full_sync
|
from http_host_lib.sync import auto_clean_btrfs, full_sync
|
||||||
from http_host_lib.versions import fetch_version_files
|
from http_host_lib.versions import fetch_version_files
|
||||||
@@ -57,7 +57,7 @@ def mount():
|
|||||||
When finished, /mnt/ofm dir will have all the present tiles.btrfs files mounted in a read-only way.
|
When finished, /mnt/ofm dir will have all the present tiles.btrfs files mounted in a read-only way.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
auto_mount_unmount()
|
auto_mount()
|
||||||
|
|
||||||
|
|
||||||
@cli.command(name='fetch-versions')
|
@cli.command(name='fetch-versions')
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from http_host_lib.config import config
|
|||||||
from http_host_lib.utils import assert_linux, assert_sudo
|
from http_host_lib.utils import assert_linux, assert_sudo
|
||||||
|
|
||||||
|
|
||||||
def auto_mount_unmount():
|
def auto_mount():
|
||||||
"""
|
"""
|
||||||
Mounts/unmounts the btrfs images from /data/ofm/http_host/runs automatically.
|
Mounts/unmounts the btrfs images from /data/ofm/http_host/runs automatically.
|
||||||
When finished, /mnt/ofm dir will have all the present tiles.btrfs files mounted in a read-only way.
|
When finished, /mnt/ofm dir will have all the present tiles.btrfs files mounted in a read-only way.
|
||||||
@@ -26,8 +26,6 @@ def auto_mount_unmount():
|
|||||||
print(' running mount -a')
|
print(' running mount -a')
|
||||||
subprocess.run(['mount', '-a'], check=True)
|
subprocess.run(['mount', '-a'], check=True)
|
||||||
|
|
||||||
clean_up_mounts(config.mnt_dir)
|
|
||||||
|
|
||||||
|
|
||||||
def create_fstab():
|
def create_fstab():
|
||||||
fstab_new = []
|
fstab_new = []
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ def create_location_blocks(*, local, domain):
|
|||||||
if not subdir.is_dir():
|
if not subdir.is_dir():
|
||||||
continue
|
continue
|
||||||
area, version = subdir.name.split('-')
|
area, version = subdir.name.split('-')
|
||||||
|
|
||||||
location_str += create_version_location(
|
location_str += create_version_location(
|
||||||
area=area, version=version, subdir=subdir, local=local, domain=domain
|
area=area, version=version, subdir=subdir, local=local, domain=domain
|
||||||
)
|
)
|
||||||
@@ -216,11 +217,13 @@ def create_latest_locations(*, local: str, domain: str) -> str:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# checking mnt dir
|
# checking mnt dir
|
||||||
mnt_file = Path(f'/mnt/ofm/{area}-{version}/metadata.json')
|
mnt_dir = Path(f'/mnt/ofm/{area}-{version}')
|
||||||
|
mnt_file = mnt_dir / ' metadata.json'
|
||||||
if not mnt_file.is_file():
|
if not mnt_file.is_file():
|
||||||
print(f' error with latest: {mnt_file} does not exist')
|
print(f' error with latest: {mnt_file} does not exist')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# latest
|
||||||
location_str += f"""
|
location_str += f"""
|
||||||
location = /{area} {{ # no trailing slash
|
location = /{area} {{ # no trailing slash
|
||||||
alias {tilejson_path}; # no trailing slash
|
alias {tilejson_path}; # no trailing slash
|
||||||
@@ -233,6 +236,38 @@ def create_latest_locations(*, local: str, domain: str) -> str:
|
|||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# wildcard
|
||||||
|
# identical to create_version_location
|
||||||
|
location_str += f"""
|
||||||
|
|
||||||
|
# wildcard JSON
|
||||||
|
location ~ ^/{area}/([^/]+)$ {{ # no trailing slash
|
||||||
|
alias {tilejson_path}; # no trailing slash
|
||||||
|
|
||||||
|
expires 1w;
|
||||||
|
default_type application/json;
|
||||||
|
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||||
|
add_header Cache-Control public;
|
||||||
|
}}
|
||||||
|
|
||||||
|
# wildcard PBF
|
||||||
|
location ~ ^/{area}/([^/]+)/ {{ # trailing slash
|
||||||
|
alias {mnt_dir}/tiles/; # trailing slash
|
||||||
|
try_files $uri @empty_tile;
|
||||||
|
add_header Content-Encoding gzip;
|
||||||
|
|
||||||
|
expires 10y;
|
||||||
|
|
||||||
|
types {{
|
||||||
|
application/vnd.mapbox-vector-tile pbf;
|
||||||
|
}}
|
||||||
|
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||||
|
add_header Cache-Control public;
|
||||||
|
}}
|
||||||
|
"""
|
||||||
|
|
||||||
return location_str
|
return location_str
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ server {
|
|||||||
ssl_prefer_server_ciphers off;
|
ssl_prefer_server_ciphers off;
|
||||||
|
|
||||||
# access log disabled by default
|
# access log disabled by default
|
||||||
#access_log /data/ofm/http_host/logs_nginx/ledns-access.jsonl access_json buffer=32k;
|
access_log /data/ofm/http_host/logs_nginx/ledns-access.jsonl access_json buffer=32k;
|
||||||
access_log off;
|
#access_log off;
|
||||||
|
|
||||||
error_log /data/ofm/http_host/logs_nginx/ledns-error.log;
|
error_log /data/ofm/http_host/logs_nginx/ledns-error.log;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from datetime import datetime, timezone
|
|||||||
from http_host_lib.assets import download_assets
|
from http_host_lib.assets import download_assets
|
||||||
from http_host_lib.btrfs import download_area_version
|
from http_host_lib.btrfs import download_area_version
|
||||||
from http_host_lib.config import config
|
from http_host_lib.config import config
|
||||||
from http_host_lib.mount import auto_mount_unmount
|
from http_host_lib.mount import auto_mount, clean_up_mounts
|
||||||
from http_host_lib.nginx import write_nginx_config
|
from http_host_lib.nginx import write_nginx_config
|
||||||
from http_host_lib.utils import assert_linux, assert_sudo
|
from http_host_lib.utils import assert_linux, assert_sudo
|
||||||
from http_host_lib.versions import fetch_version_files
|
from http_host_lib.versions import fetch_version_files
|
||||||
@@ -42,9 +42,12 @@ def full_sync(force=False):
|
|||||||
|
|
||||||
if btrfs_downloaded or versions_changed or force:
|
if btrfs_downloaded or versions_changed or force:
|
||||||
auto_clean_btrfs()
|
auto_clean_btrfs()
|
||||||
auto_mount_unmount()
|
auto_mount()
|
||||||
|
|
||||||
write_nginx_config()
|
write_nginx_config()
|
||||||
|
|
||||||
|
clean_up_mounts(config.mnt_dir)
|
||||||
|
|
||||||
|
|
||||||
def auto_clean_btrfs():
|
def auto_clean_btrfs():
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ LOG_DIR=/data/ofm/tile_gen/logs
|
|||||||
# every minute, set monaco to latest
|
# every minute, set monaco to latest
|
||||||
* * * * * ofm $CMD set-version monaco >> $LOG_DIR/monaco-set-version.log 2>&1
|
* * * * * ofm $CMD set-version monaco >> $LOG_DIR/monaco-set-version.log 2>&1
|
||||||
|
|
||||||
# every Tuesday morning at 00:10, make a planet run
|
# every Wednesday morning at 00:10, make a planet run
|
||||||
10 0 * * 2 ofm $CMD make-tiles planet --upload >> $LOG_DIR/planet-make-tiles.log 2>&1
|
10 0 * * 3 ofm $CMD make-tiles planet --upload >> $LOG_DIR/planet-make-tiles.log 2>&1
|
||||||
|
|
||||||
# every Saturday at 8:00, set planet to latest
|
# every Saturday at 8:00, set planet to latest
|
||||||
0 11 * * 6 ofm $CMD set-version monaco >> $LOG_DIR/monaco-set-version.log 2>&1
|
0 11 * * 6 ofm $CMD set-version monaco >> $LOG_DIR/monaco-set-version.log 2>&1
|
||||||
|
|||||||
Reference in New Issue
Block a user