UNPKG

644 BJavaScriptView Raw
1'use strict';
2
3
4require.main.paths.unshift(process.cwd() + '/node_modules');
5
6
7const boot = require.main.require('@fragmento/server-hapi');
8
9
10;
11(async() => {
12
13 try {
14 console.log('[server-hapi] starting ...');
15 let server = await boot(process.cwd());
16 console.log('[server-hapi] ready\n', server.info);
17
18
19
20 process.once('SIGUSR2', async function() {
21 console.log('[server-hapi] stopping ...');
22 await server.stop();
23 //await new Promise(resolve => setTimeout(resolve, 1000));
24 console.log('[server-hapi] stopped');
25 process.kill(process.pid, 'SIGUSR2');
26 });
27 } catch (e) {
28 console.log('retry', e)
29 process.exit(1);
30 }
31
32})();