Skip to content

Commit

Permalink
use a distinct envvar to set daemon listen ports when running Express…
Browse files Browse the repository at this point in the history
… natively
  • Loading branch information
hotzevzl committed Nov 11, 2021
1 parent 3e4731c commit 33fb990
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ details.
* `API_AUTH_X_API_KEY` (string, required): a secret used as API key for
requests from the Geoprocessing service to the API; can be generated
similarly to `API_AUTH_JWT_SECRET`
* `API_SERVICE_PORT` (number, required): the port on which the API service
should listen on the local machine
* `API_SERVICE_PORT` (number, required): the port exposed by Docker for the
API service; when running an instance under Docker Compose, NestJS will
always be listening on port 3000 internally, and this is mapped to
`API_SERVICE_PORT` when exposed outside of the container
* `API_SERVICE_URL` (URL, optional, default is http://api:3000): the internal
(docker-compose or k8s cluster) where the API service can be reached by
other services running in the cluster
Expand Down Expand Up @@ -67,8 +69,11 @@ details.
PostgreSQL connection (API)
* `API_POSTGRES_DB` (string, required): name of the database to be used for
the PostgreSQL connection (API)
* `GEOPROCESSING_SERVICE_PORT` (number, required): the port on which the
Geoprocessing service should listen on the local machine
* `GEOPROCESSING_SERVICE_PORT` (number, required): the port exposed by Docker
for the Geoprocessing service; when running an instance under Docker
Compose, NestJS will always be listening on port 3000 internally, and this
is mapped to `GEOPROCESSING_SERVICE_PORT` when exposed outside of the
container
* `POSTGRES_GEO_SERVICE_PORT` (number, required): the port on which the
geoprocessing PostgreSQL service should listen on the local machine
* `GEOPROCESSING_RUN_MIGRATIONS_ON_STARTUP`: (`true|false`, optional, default
Expand Down Expand Up @@ -110,6 +115,18 @@ The PostgreSQL credentials are used to create a database user when the
PostgreSQL container is started for the first time. PostgreSQL data is persisted
via a Docker volume.

#### Running API and Geoprocessing services natively

When running the API and Geoprocessing services without relying on Docker
Compose for container orchestration, the following two environment variables can
be used to set on which port the NestJS/Express daemon should be listening,
instead of the hardcoded port `3000` which is used in Docker setups.

* `API_DAEMON_LISTEN_PORT` (number, optional, default is 3000): port on which
the Express daemon of the API service will listen
* `GEOPROCESSING_DAEMON_LISTEN_PORT` (number, optional, default is 3000): port
on which the Express daemon of the Geoprocessing service will listen

### Running the Marxan Cloud platform

Run `make start` to start all the services.
Expand Down
2 changes: 1 addition & 1 deletion api/apps/api/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"api": {
"url": "API_SERVICE_URL",
"port": "API_SERVICE_PORT"
"daemonListenPort": "API_DAEMON_LISTEN_PORT"
},
"storage": {
"sharedFileStorage": {
Expand Down
2 changes: 1 addition & 1 deletion api/apps/api/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"api": {
"url": "http://api:3000",
"port": 3000
"daemonListenPort": 3000
},
"jobOptions":{
"removeOnComplete": 100,
Expand Down
2 changes: 1 addition & 1 deletion api/apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function bootstrap() {

SwaggerModule.setup('/swagger', app, swaggerDocument);

await app.listen(AppConfig.get('api.port'));
await app.listen(AppConfig.get('api.daemonListenPort'));
}

bootstrap();
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"url": "API_SERVICE_URL"
},
"geo": {
"port": "GEO_SERVICE_PORT"
"daemonListenPort": "GEO_DAEMON_LISTEN_PORT"
},
"storage": {
"sharedFileStorage": {
Expand Down
2 changes: 1 addition & 1 deletion api/apps/geoprocessing/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "http://api:3000"
},
"geo": {
"port": 3000
"daemonListenPort": 3000
},
"storage": {
"sharedFileStorage": {
Expand Down
2 changes: 1 addition & 1 deletion api/apps/geoprocessing/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ async function bootstrap() {
}),
);
app.useGlobalFilters(new AllExceptionsFilter());
await app.listen(AppConfig.get('geo.port'));
await app.listen(AppConfig.get('geo.daemonListenPort'));
}
bootstrap();

0 comments on commit 33fb990

Please sign in to comment.