Database setup
Panoramax API relies on a PostgreSQL 14+ database with PostGIS 3.4+ extension to run.
Note
The recommended PostgreSQL version is 15+, since this way, granular permissions can be granted to the user.
You can use your own existing PostgreSQL server, a cloud-managed PostgreSQL database, or have PostgreSQL running in our Docker files. If you want to install your own PostgreSQL server, refer to these software documentation to know more about their install.
Danger
For production-grade deployment, be sure that your database is backuped, it would be a shame to loose all your data !
Once your PostgreSQL server is ready and running, we recommend you to do the following:
- Add a system/OS user named
panoramax, for example under Linux:
Tip
On older version of this documentation, the user was named geovisio, that is the case for your setup, either rename your user, or adapt the following commands.
- Create a PostgreSQL role
panoramaxwith this command:
- Create a new database (with UTF-8 encoding) using this command:
$ sudo su - postgres -c "psql -c \"CREATE DATABASE panoramax ENCODING 'UTF-8' TEMPLATE template0 OWNER panoramax\""
- Enable PostGIS extension in your database:
- Make sure your database is running at UTC timezone:
- If postgres 15+ is used, grant
session_replication_role, so that sql migrations can be non blocking.
$ sudo su - postgres -c "psql -d panoramax -c \"GRANT SET ON PARAMETER session_replication_role TO panoramax\""
else, the user must have superuser privilege (but it's way better to only grant session_replication_role):
Note
This is not mandatory, and the migrations should work without it, but the migrations process will be slower and might block the database for a while.
Estimation of the number of needed connections
Multiple processes will need to access the database. Each process maintain their own connection pool, and it is possible to configure the size of those pool for each workers (using the environment variables DB_MIN_CNX/DB_MAX_CNX, cf documentation).
To know how many connections will be needed, you need to sum the maximum number of connections for: - each api threads/process - each background workers
For example, by default, when using the docker compose provided in the tutorials, the maximum number of connections on the api is: - 4 api threads * 10 - 5 upload workers * 4 - 3 base workers * 4 - 1 cron worker * 2
So, by default, a maximum of 74 connections to the database will be needed (and computed the same way, the minimum number of created connections will be 12).
Troubleshooting
Got some issues on this part ? Here are a few hints that may help.
- PostgreSQL server is not listening ?
- Check the postgresql.conf file and verify that
listen_adressesis set to* - PostgreSQL says
Peer authentication failed? - Check your pg_hba.conf file and verify that a rule exist to allow your
panoramaxuser or any other OS user to login into your database - This is particularly useful if you're running only Panoramax API in Docker, with a PostgreSQL database server on your host, where database IP address might look like
172.17.0.*. You may have to add an entry like this to allow login: