Skip to content

Commit 4f7f280

Browse files
committed
fix(shutdown): stop using process.kill in SIGTERM
1 parent fc18bb5 commit 4f7f280

4 files changed

Lines changed: 17 additions & 11 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/core",
3-
"version": "5.35.0",
3+
"version": "5.36.0",
44
"description": "One foundation for multiple applications.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/helpers/LoadHelper.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,21 @@ export class LoadHelper {
6868
await this.providers.athenna.concurrently(Provider => {
6969
debug('running shutdown() method of provider %s.', Provider.name)
7070

71-
if (Config.is('rc.shutdownLogs', true)) {
71+
const log = () => {
7272
Log.channelOrVanilla('application').success(
7373
`Provider ({yellow} ${Provider.name}) successfully shutdown`
7474
)
7575
}
7676

77-
return new Provider().shutdown() as Promise<void>
77+
const shutdown = new Provider().shutdown() as Promise<void>
78+
79+
if (!shutdown?.then) {
80+
log()
81+
82+
return
83+
}
84+
85+
return shutdown.then(() => log())
7886
})
7987
}
8088

src/ignite/Ignite.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type {
2020
} from '#src/types'
2121

2222
import { Ioc } from '@athenna/ioc'
23+
import { debug } from '#src/debug'
2324
import { Cron } from '#src/applications/Cron'
2425
import { Http } from '#src/applications/Http'
2526
import type { ServerImpl } from '@athenna/http'
@@ -35,7 +36,6 @@ import { Repl as ReplApp } from '#src/applications/Repl'
3536
import { parse as semverParse, satisfies as semverSatisfies } from 'semver'
3637
import { Is, Path, File, Module, Options, Macroable } from '@athenna/common'
3738
import { NotSatisfiedNodeVersion } from '#src/exceptions/NotSatisfiedNodeVersion'
38-
import { debug } from '#src/debug/index'
3939

4040
export class Ignite extends Macroable {
4141
/**
@@ -380,15 +380,13 @@ export class Ignite extends Macroable {
380380

381381
if (!signals.SIGINT) {
382382
signals.SIGINT = () => {
383-
process.exit()
383+
process.exit(0)
384384
}
385385
}
386386

387387
if (!signals.SIGTERM) {
388-
signals.SIGTERM = signal => {
389-
LoadHelper.shutdownProviders().then(() =>
390-
process.kill(process.pid, signal)
391-
)
388+
signals.SIGTERM = () => {
389+
LoadHelper.shutdownProviders().then(() => process.exit(0))
392390
}
393391
}
394392

0 commit comments

Comments
 (0)