Open
Conversation
Akasch
requested changes
May 29, 2020
| def _create_postgres_db(self): | ||
| # create new postgresql cluster | ||
| print_stage('Creating PostgreSQL cluster') | ||
| db_dir = os.path.join(self.working_dir, 'pg_data') |
Member
There was a problem hiding this comment.
This will do unexpected things if one starts two containers to process in parallel with the same dirs, maybe also use the tilecoordinates?
| db_dir = os.path.join(self.working_dir, 'pg_data') | ||
| subprocess.run(['rm', '-rf', db_dir], check=True) | ||
| os.makedirs(db_dir) | ||
| subprocess.run(['pg_createcluster', PG_VERSION, 'main', '--start', '--datadir', db_dir], check=True, |
Member
There was a problem hiding this comment.
We prpably should edit the configuration of the database and allow more RAM use
| print_stage("Importing data with osm2pgsql") | ||
| subprocess.run([ | ||
| 'su', 'postgres', '-c', | ||
| f'osm2pgsql --slim --hstore-all -C 3000 ' |
Member
There was a problem hiding this comment.
is the 3000 a good choice for RAM usage?
Contributor
Author
There was a problem hiding this comment.
that's what the original script used
| f'-P {self.db_port} ' | ||
| f'-U postgres ' | ||
| f'--number-processes {max(1, os.cpu_count() - 2)} ' | ||
| f'{os.path.join(self.working_dir, self.pbf_file_name)}' |
Member
There was a problem hiding this comment.
use unchecked tables as we will drop it later on?
| with open(file_path, 'wb') as f: | ||
| subprocess.run(['su', 'postgres', '-c', | ||
| f'pg_dump -p {self.db_port} -d {self.db_dbname} --format custom'], | ||
| check=True, cwd=self.out_dir, stdout=f) |
| print_stage('Uploading PostgreSQL dump to tileserver-mapping') | ||
| file_path = os.path.join(self.working_dir, 'db.pg_dump') | ||
| self.api.upload_sql_dump(self.tile, file_path) | ||
| subprocess.run(['rsync', file_path, self.out_dir], check=True) |
Member
There was a problem hiding this comment.
if it is uploaded i would not put it into local storage, it would only waste space
| def _upload_dump(self): | ||
| print_stage('Uploading PostgreSQL dump to tileserver-mapping') | ||
| file_path = os.path.join(self.working_dir, 'db.pg_dump') | ||
| self.api.upload_sql_dump(self.tile, file_path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This depends on Map-Data/tileserver-mapping#10
I tried reproducing the steps from https://github.com/Map-Data/regiontileserver/blob/master/import_data.sh as much as possible with the addition of coordinating files to tileserver-mapping.