Skip to content

Commit

Permalink
feat sigterm-safe deployment (#619) (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
veckatimest authored May 22, 2024
1 parent 3d74e72 commit 6f71d67
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion build/production/core-api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
containers:
- name: core-api
image: 887044485231.dkr.ecr.eu-west-1.amazonaws.com/core-api:latest
args: ["yarn", "start:core"]
command: ["node"]
args: ["core/main.js"]
readinessProbe:
httpGet:
path: /health-check
Expand Down
3 changes: 2 additions & 1 deletion build/production/core-tasks/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
containers:
- name: core-tasks
image: 887044485231.dkr.ecr.eu-west-1.amazonaws.com/core-tasks:latest
args: ["yarn", "start:tasks"]
command: ["node"]
args: ["tasks/main.js"]
envFrom:
- secretRef:
name: core-secrets
Expand Down
3 changes: 2 additions & 1 deletion build/production/media-api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
containers:
- name: media-api
image: 887044485231.dkr.ecr.eu-west-1.amazonaws.com/core-api:latest
args: ["yarn", "start:core"]
command: ["node"]
args: ["core/main.js"]
readinessProbe:
httpGet:
path: /health-check
Expand Down
3 changes: 2 additions & 1 deletion build/production/noncore-api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
containers:
- name: noncore-api
image: 887044485231.dkr.ecr.eu-west-1.amazonaws.com/noncore-api:latest
args: ["yarn", "start:noncore"]
command: ["node"]
args: ["noncore/main.js"]
readinessProbe:
httpGet:
path: /v1/health-check
Expand Down
3 changes: 2 additions & 1 deletion build/production/noncore-mqtt/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
containers:
- name: noncore-mqtt
image: 887044485231.dkr.ecr.eu-west-1.amazonaws.com/noncore-mqtt:latest
args: ["yarn", "start:mqtt"]
command: ["node"]
args: ["mqtt/main.js"]
envFrom:
- secretRef:
name: noncore-secrets
Expand Down
3 changes: 2 additions & 1 deletion build/staging/core-api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
containers:
- name: core-api
image: 887044485231.dkr.ecr.eu-west-1.amazonaws.com/core-api:latest
args: ["yarn", "start:core"]
command: ["node"]
args: ["core/main.js"]
readinessProbe:
httpGet:
path: /health-check
Expand Down
3 changes: 2 additions & 1 deletion build/staging/core-tasks/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
containers:
- name: core-tasks
image: 887044485231.dkr.ecr.eu-west-1.amazonaws.com/core-tasks:latest
args: ["yarn", "start:tasks"]
command: ["node"]
args: ["tasks/main.js"]
envFrom:
- secretRef:
name: core-secrets
Expand Down
3 changes: 2 additions & 1 deletion build/staging/noncore-api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
containers:
- name: noncore-api
image: 887044485231.dkr.ecr.eu-west-1.amazonaws.com/noncore-api:latest
args: ["yarn", "start:noncore"]
command: ["node"]
args: ["noncore/main.js"]
readinessProbe:
httpGet:
path: /v1/health-check
Expand Down
3 changes: 2 additions & 1 deletion build/staging/noncore-mqtt/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
containers:
- name: noncore-mqtt
image: 887044485231.dkr.ecr.eu-west-1.amazonaws.com/noncore-mqtt:latest
args: ["yarn", "start:mqtt"]
command: ["node"]
args: ["mqtt/main.js"]
envFrom:
- secretRef:
name: noncore-secrets
Expand Down
9 changes: 6 additions & 3 deletions core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ process.on('uncaughtException', (error) => {
})

function handle (signal) {
emergencyLogger.error(`Received ${signal}, exiting`)
emergencyLogger.error(`Received SIGNAL ${signal}, exiting`)

server.close((error) => {
server.close(async (error) => {
if (error) {
emergencyLogger.error(`Failed to gracefully shutdown server with error ${error.stack}`)
process.exit(1)
}
emergencyLogger.info(`On SIGNAL ${signal} succesfully closed the server`)

sequelize.close()
await sequelize.close()

emergencyLogger.info(`On SIGNAL ${signal} Succesfully closed the sequelize`)

process.exit()
})
Expand Down

0 comments on commit 6f71d67

Please sign in to comment.