-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#581 Add adjecent servers (stac, tipg, titiler, titiler-pgstac) and p…
…roxies to npm start
- Loading branch information
1 parent
1a5c437
commit 529747a
Showing
18 changed files
with
621 additions
and
151 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
require("dotenv").config(); | ||
const logger = require("../API/logger"); | ||
const { spawn } = require("child_process"); | ||
|
||
const IS_WINDOWS = /^win/i.test(process.platform) ? true : false; | ||
const EXT = IS_WINDOWS ? ".bat" : ".sh"; | ||
|
||
const adjacentServers = [ | ||
{ | ||
name: "stac", | ||
command: `cd adjacent-servers/stac/ && start-stac${EXT}`, | ||
port: process.env.STAC_PORT || 8881, | ||
env: "WITH_STAC", | ||
}, | ||
{ | ||
name: "tipg", | ||
command: `cd adjacent-servers/tipg/ && start-tipg${EXT}`, | ||
port: process.env.TIPG_PORT || 8882, | ||
env: "WITH_TIPG", | ||
}, | ||
{ | ||
name: "titiler", | ||
command: `cd adjacent-servers/titiler/ && start-titiler${EXT}`, | ||
port: process.env.TITILER_PORT || 8883, | ||
env: "WITH_TITILER", | ||
}, | ||
{ | ||
name: "titiler-pgstac", | ||
command: `cd adjacent-servers/titiler-pgstac/ && start-titiler-pgstac${EXT}`, | ||
port: process.env.TITILER_PGSTAC_PORT || 8884, | ||
env: "WITH_TITILER_PGSTAC", | ||
}, | ||
]; | ||
|
||
const serverProcesses = []; | ||
adjacentServers.forEach((s) => { | ||
if (process.env[s.env] === "true") { | ||
logger( | ||
"info", | ||
`Starting ${s.name} server on port ${s.port}...`, | ||
"adjacent-servers" | ||
); | ||
let cmd = spawn(s.command, [s.port], { shell: true }); | ||
serverProcesses.push(cmd); | ||
|
||
cmd.stdout.on("data", (data) => { | ||
if (`${data}`.indexOf("running") != -1) | ||
process.stdout.write(`${s.name} - ${data}`); | ||
}); | ||
|
||
cmd.stderr.on("data", (data) => { | ||
if (`${data}`.indexOf("running") != -1) | ||
process.stdout.write(`${s.name} - ${data}`); | ||
}); | ||
|
||
cmd.on("error", (err) => { | ||
process.stdout.write(`${s.name} ERROR - ${err}`); | ||
}); | ||
} | ||
}); | ||
|
||
let running = true; | ||
|
||
function killProcess() { | ||
logger("info", `Terminating adjacent servers...`, "adjacent-servers"); | ||
serverProcesses.forEach((process) => { | ||
process.kill(); | ||
}); | ||
logger( | ||
"success", | ||
`Successfully terminated all adjacent servers.`, | ||
"adjacent-servers" | ||
); | ||
running = false; | ||
} | ||
|
||
process.on("SIGTERM", killProcess); | ||
process.on("SIGINT", killProcess); | ||
process.on("uncaughtException", function (e) { | ||
logger( | ||
"error", | ||
`[uncaughtException] app will be terminated: ${e.stack}`, | ||
"adjacent-servers" | ||
); | ||
killProcess(); | ||
}); | ||
|
||
function run() { | ||
setTimeout(function () { | ||
if (running) run(); | ||
}, 1000); | ||
} | ||
|
||
run(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
POSTGRES_USER= | ||
POSTGRES_PASS= | ||
POSTGRES_DBNAME= | ||
POSTGRES_HOST=localhost | ||
POSTGRES_HOST_READER=localhost | ||
POSTGRES_HOST_WRITER=localhost | ||
POSTGRES_PORT=5432 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:: ############################################################################### | ||
:: STAC | ||
dotenv run python -m uvicorn stac_fastapi.pgstac.app:app --port %1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
############################################################################### | ||
# STAC | ||
dotenv run python -m uvicorn stac_fastapi.pgstac.app:app --port $1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# DB_MAX_CONN_SIZE need to be at least the same size as WEB_CONCURRENCY | ||
DB_MIN_CONN_SIZE=1 | ||
DB_MAX_CONN_SIZE=10 | ||
DB_MAX_QUERIES=10 | ||
DB_MAX_IDLE=10 | ||
|
||
WEB_CONCURRENCY=10 | ||
|
||
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} | ||
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} | ||
CPL_TMPDIR=/tmp | ||
GDAL_CACHEMAX=75% | ||
GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR | ||
GDAL_HTTP_MERGE_CONSECUTIVE_RANGES=YES | ||
GDAL_HTTP_MULTIPLEX=YES | ||
GDAL_HTTP_VERSION=2 | ||
|
||
PYTHONWARNINGS=ignore | ||
VSI_CACHE=TRUE | ||
VSI_CACHE_SIZE=536870912 | ||
|
||
MOSAIC_CONCURRENCY=1 | ||
DEBUG=TRUE | ||
|
||
TITILER_PGSTAC_API_DEBUG=TRUE | ||
|
||
POSTGRES_USER= | ||
POSTGRES_PASS= | ||
POSTGRES_DBNAME= | ||
POSTGRES_HOST=localhost | ||
POSTGRES_PORT=5432 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
: ############################################################################### | ||
:: tipg | ||
dotenv run python -m uvicorn tipg.main:app --port %1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
############################################################################### | ||
# tipg | ||
dotenv run python -m uvicorn tipg.main:app --port $1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# DB_MAX_CONN_SIZE need to be at least the same size as WEB_CONCURRENCY | ||
DB_MIN_CONN_SIZE=1 | ||
DB_MAX_CONN_SIZE=10 | ||
DB_MAX_QUERIES=10 | ||
DB_MAX_IDLE=10 | ||
|
||
WEB_CONCURRENCY=10 | ||
|
||
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} | ||
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} | ||
CPL_TMPDIR=/tmp | ||
GDAL_CACHEMAX=75% | ||
GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR | ||
GDAL_HTTP_MERGE_CONSECUTIVE_RANGES=YES | ||
GDAL_HTTP_MULTIPLEX=YES | ||
GDAL_HTTP_VERSION=2 | ||
|
||
PYTHONWARNINGS=ignore | ||
VSI_CACHE=TRUE | ||
VSI_CACHE_SIZE=536870912 | ||
|
||
MOSAIC_CONCURRENCY=1 | ||
DEBUG=TRUE | ||
|
||
TITILER_PGSTAC_API_DEBUG=TRUE | ||
|
||
POSTGRES_USER= | ||
POSTGRES_PASS= | ||
POSTGRES_DBNAME= | ||
POSTGRES_HOST=localhost | ||
POSTGRES_PORT=5432 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
:: ############################################################################### | ||
:: TiTiler-pgSTAC | ||
dotenv run python -m uvicorn titiler.pgstac.main:app --port %1 | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
############################################################################### | ||
# TiTiler-pgSTAC | ||
dotenv run python -m uvicorn titiler.pgstac.main:app --port $1 |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:: ############################################################################### | ||
:: TiTiler | ||
dotenv run python -m uvicorn titiler.application.main:app --port %1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
############################################################################### | ||
# TiTiler | ||
dotenv run python -m uvicorn titiler.application.main:app --port $1 |
Oops, something went wrong.