• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

badges / shields / 13893658896

16 Mar 2025 10:11PM UTC coverage: 93.149% (-0.002%) from 93.151%
13893658896

push

github

web-flow
graceful shutdown (#10958)

* graceful shutdown

The main entrypoint now handles the SIGTERM signal and stops the server.

* Don't call process.exit on shutdown

That is not graceful in nodejs, see https://kostasbariotis.com/why-you-should-not-use-process-exit/

5988 of 6250 branches covered (95.81%)

3 of 5 new or added lines in 1 file covered. (60.0%)

1 existing line in 1 file now uncovered.

50687 of 54415 relevant lines covered (93.15%)

116.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.43
/server.js
1
import fs from 'fs'
1✔
2
import path from 'path'
1✔
3
import { fileURLToPath } from 'url'
1✔
4
import configModule from 'config'
1✔
5
import * as Sentry from '@sentry/node'
1✔
6
import Server from './core/server/server.js'
1✔
7

1✔
8
// Set up Sentry reporting as early in the process as possible.
1✔
9
const config = configModule.util.toObject()
1✔
10
const disabledIntegrations = ['Console', 'Http']
1✔
11
Sentry.init({
1✔
12
  dsn: process.env.SENTRY_DSN || config.private.sentry_dsn,
1✔
13
  integrations: integrations => {
1✔
14
    const filtered = integrations.filter(
1✔
15
      integration => !disabledIntegrations.includes(integration.name),
1✔
16
    )
1✔
17
    if (filtered.length !== integrations.length - disabledIntegrations.length) {
1!
18
      throw Error(
×
19
        `An error occurred while filtering integrations. The following inetgrations were found: ${integrations.map(
×
20
          ({ name }) => name,
×
21
        )}`,
×
22
      )
×
23
    }
×
24
    return filtered
1✔
25
  },
1✔
26
})
1✔
27

1✔
28
if (+process.argv[2]) {
1!
29
  config.public.bind.port = +process.argv[2]
×
30
}
×
31
if (process.argv[3]) {
1!
32
  config.public.bind.address = process.argv[3]
×
33
}
×
34

1✔
35
console.log('Configuration:')
1✔
36
console.dir(config.public, { depth: null })
1✔
37

1✔
38
if (fs.existsSync('.env')) {
1!
39
  console.error(
×
40
    'Legacy .env file found. It should be deleted and replaced with environment variables or config/local.yml',
×
41
  )
×
42
  process.exit(1)
×
43
}
×
44

1✔
45
if (config.private.redis_url != null) {
1!
46
  console.error(
×
47
    'RedisTokenPersistence has been removed. Migrate to SqlTokenPersistence',
×
48
  )
×
49
  process.exit(1)
×
50
}
×
51

1✔
52
const legacySecretsPath = path.join(
1✔
53
  path.dirname(fileURLToPath(import.meta.url)),
1✔
54
  'private',
1✔
55
  'secret.json',
1✔
56
)
1✔
57
if (fs.existsSync(legacySecretsPath)) {
1!
58
  console.error(
×
59
    `Legacy secrets file found at ${legacySecretsPath}. It should be deleted and secrets replaced with environment variables or config/local.yml`,
×
60
  )
×
61
  process.exit(1)
×
62
}
×
63
export const server = new Server(config)
1✔
64

1✔
65
process.on('SIGTERM', async () => {
1✔
NEW
66
  console.log('SIGTERM received, shutting down...')
×
NEW
67
  await server.stop()
×
68
})
1✔
69

1✔
70
await server.start()
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc