Skip to content

Commit c7c2d8d

Browse files
committed
Spin up multiple instances via ci cmd. Allow stopping server via API
1 parent e3fed37 commit c7c2d8d

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ COPY . .
99
EXPOSE 8080
1010
ENV ENV_RUN_AS "docker"
1111
HEALTHCHECK --interval=1s --timeout=10s --retries=2 \
12-
CMD curl -m 10 -f http://localhost:8080/health || kill 1
12+
CMD curl -m 10 -f http://localhost:8080/health || kill 1
1313
ENTRYPOINT [ "ts-node" , "src/index.ts"]

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build": "tsc",
1313
"start": "ts-node ./src/index.ts",
1414
"dev": "nodemon src/index.ts",
15-
"ci": "pm2 start src/index.ts --interpreter ts-node --exp-backoff-restart-delay=100 --name terrarium"
15+
"ci": "pm2 start src/index.ts --interpreter ts-node --exp-backoff-restart-delay=100 --name terrarium -i max"
1616
},
1717
"devDependencies": {
1818
"node-fetch": "^3.3.2",

src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ terrariumApp.get('/health', (req, res) => {
6363
res.send("hi!");
6464
});
6565

66+
terrariumApp.get('/stop', (req, res) => {
67+
process.exit(1); // Force stop the server
68+
});
6669

6770
const server = terrariumApp.listen(8080, () => {
6871
console.log("Server is running on port 8080");

0 commit comments

Comments
 (0)