kopia lustrzana https://github.com/kartoza/docker-osm
Made changes
rodzic
7bb7ff699d
commit
09c7d382b6
|
@ -6,7 +6,7 @@ RUN wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key a
|
||||||
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
|
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
|
||||||
RUN apt update && apt install -y python3-pip \
|
RUN apt update && apt install -y python3-pip \
|
||||||
libprotobuf-dev libleveldb-dev libgeos-dev \
|
libprotobuf-dev libleveldb-dev libgeos-dev \
|
||||||
libpq-dev python3-dev postgresql-client-11 python-setuptools \
|
libpq-dev python3-dev postgresql-client-12 python-setuptools \
|
||||||
gdal-bin \
|
gdal-bin \
|
||||||
--no-install-recommends
|
--no-install-recommends
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from sys import exit, stderr
|
from sys import exit, stderr
|
||||||
from os import environ, listdir
|
from os import environ, listdir, path, mknod, remove
|
||||||
from shutil import move
|
from shutil import move
|
||||||
from os.path import join, exists, abspath, isabs
|
from os.path import join, exists, abspath, isabs
|
||||||
from psycopg2 import connect, OperationalError
|
from psycopg2 import connect, OperationalError
|
||||||
|
@ -253,7 +253,7 @@ class Importer(object):
|
||||||
call(command)
|
call(command)
|
||||||
|
|
||||||
def perform_cron(self):
|
def perform_cron(self):
|
||||||
cron_sql = """ SELECT cron.schedule('*/59 * * * *', $$select clean_tables()$$); """
|
cron_sql = """ SELECT cron.schedule('*/20 * * * *', $$select clean_tables()$$); """
|
||||||
self.cursor.execute(cron_sql)
|
self.cursor.execute(cron_sql)
|
||||||
|
|
||||||
def locate_table(self, name):
|
def locate_table(self, name):
|
||||||
|
@ -273,6 +273,12 @@ class Importer(object):
|
||||||
|
|
||||||
call(clipper, shell=True)
|
call(clipper, shell=True)
|
||||||
|
|
||||||
|
def create_lock_file(self):
|
||||||
|
importer_lockfile = path.join(self.default['SETTINGS'], '.importer.lock')
|
||||||
|
remove(importer_lockfile)
|
||||||
|
if not path.exists(importer_lockfile):
|
||||||
|
mknod(importer_lockfile)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""First checker."""
|
"""First checker."""
|
||||||
osm_tables = self.locate_table('osm_%')
|
osm_tables = self.locate_table('osm_%')
|
||||||
|
@ -282,8 +288,11 @@ class Importer(object):
|
||||||
|
|
||||||
if self.clip_json_file:
|
if self.clip_json_file:
|
||||||
self._first_pbf_import(['-limitto', self.clip_json_file])
|
self._first_pbf_import(['-limitto', self.clip_json_file])
|
||||||
|
self.create_lock_file()
|
||||||
else:
|
else:
|
||||||
self._first_pbf_import([])
|
self._first_pbf_import([])
|
||||||
|
self.create_lock_file()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.info(
|
self.info(
|
||||||
'The database is not empty. Let\'s import only diff files.')
|
'The database is not empty. Let\'s import only diff files.')
|
||||||
|
|
|
@ -6,10 +6,6 @@ RUN pip3 install -r /home/requirements.txt
|
||||||
|
|
||||||
ADD enrich.py /home/
|
ADD enrich.py /home/
|
||||||
|
|
||||||
RUN if [ ! -f /home/check_tables.sql ]; then \
|
|
||||||
echo "SELECT EXISTS (SELECT 1 AS result from information_schema.tables where table_name like 'osm_%');" >> /home/check_tables.sql;\
|
|
||||||
fi;
|
|
||||||
|
|
||||||
WORKDIR /home
|
WORKDIR /home
|
||||||
CMD ["python3", "-u", "/home/enrich.py"]
|
CMD ["python3", "-u", "/home/enrich.py"]
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue