There are two parts to UK Explr:
-
To create a database from raw data files. See: Initialise Database.
-
To serve the data through a REST API endpoint. See: Serve Query API.
- Create
.envfile in project root directory based on.env.example.
-
Optional. Clear the existing database, if any:
npm run uninit -
Initialise the new database:
npm run init -
Start the migration:
npm run migrate
-
Start the web server:
npm run serve -
Make
GETrequest(s) to route:/v1/query-resultNote that:
-
The query string is parsed to using the
qspackage. -
Query parameters are described by the
QueryRequestschema object.
-
This is due to Postgres not unlocking the lookup table due to a race condition.
To resolve this issue, first cancel execution of the migration script (using the Control + C keys).
Next, find the process that has locked the table using the command:
lsof -i :<value of PG_PORT in env file>
You should first check the machine from which the migration script is executed (this will likely be a node process).
If no process can be found on the machine from which the migration script is executed, then check the machine hosting the Postgres database (this will likely be a postgres process that is NOT the database server, but represents a network connection to the database).
Once the process is identified, kill the process:
kill -9 <identified process id>
where -9 corresponds to SIGKILL
It might take more than one attempt to kill the process; when the process is killed, the command should print: no such process.
You can now rerun the migration script.