aboutsummaryrefslogtreecommitdiffstats
path: root/bin/server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'bin/server.ts')
-rw-r--r--bin/server.ts30
1 files changed, 15 insertions, 15 deletions
diff --git a/bin/server.ts b/bin/server.ts
index fe0fefb..40789e3 100644
--- a/bin/server.ts
+++ b/bin/server.ts
@@ -9,14 +9,14 @@
9| 9|
10*/ 10*/
11 11
12import 'reflect-metadata' 12import 'reflect-metadata';
13import { Ignitor, prettyPrintError } from '@adonisjs/core' 13import { Ignitor, prettyPrintError } from '@adonisjs/core';
14 14
15/** 15/**
16 * URL to the application root. AdonisJS need it to resolve 16 * URL to the application root. AdonisJS need it to resolve
17 * paths to file and directories for scaffolding commands 17 * paths to file and directories for scaffolding commands
18 */ 18 */
19const APP_ROOT = new URL('../', import.meta.url) 19const APP_ROOT = new URL('../', import.meta.url);
20 20
21/** 21/**
22 * The importer is used to import files in context of the 22 * The importer is used to import files in context of the
@@ -24,22 +24,22 @@ const APP_ROOT = new URL('../', import.meta.url)
24 */ 24 */
25const IMPORTER = (filePath: string) => { 25const IMPORTER = (filePath: string) => {
26 if (filePath.startsWith('./') || filePath.startsWith('../')) { 26 if (filePath.startsWith('./') || filePath.startsWith('../')) {
27 return import(new URL(filePath, APP_ROOT).href) 27 return import(new URL(filePath, APP_ROOT).href);
28 } 28 }
29 return import(filePath) 29 return import(filePath);
30} 30};
31 31
32new Ignitor(APP_ROOT, { importer: IMPORTER }) 32new Ignitor(APP_ROOT, { importer: IMPORTER })
33 .tap((app) => { 33 .tap(app => {
34 app.booting(async () => { 34 app.booting(async () => {
35 await import('#start/env') 35 await import('#start/env');
36 }) 36 });
37 app.listen('SIGTERM', () => app.terminate()) 37 app.listen('SIGTERM', () => app.terminate());
38 app.listenIf(app.managedByPm2, 'SIGINT', () => app.terminate()) 38 app.listenIf(app.managedByPm2, 'SIGINT', () => app.terminate());
39 }) 39 })
40 .httpServer() 40 .httpServer()
41 .start() 41 .start()
42 .catch((error) => { 42 .catch(error => {
43 process.exitCode = 1 43 process.exitCode = 1;
44 prettyPrintError(error) 44 prettyPrintError(error);
45 }) 45 });