forked from jsreport/jsreport
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (35 loc) · 760 Bytes
/
server.js
File metadata and controls
38 lines (35 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const jsreport = require('jsreport')({
rootDirectory: __dirname
})
if (process.env.JSREPORT_CLI) {
// export jsreport instance to make it possible to use jsreport-cli
module.exports = jsreport
} else {
jsreport.init().then(() => {
// running
}).catch((e) => {
// error during startup
console.error(e)
process.exit(1)
})
}
async function shutdown () {
try {
await jsreport.close()
process.exit(0)
} catch (e) {
console.error(e)
process.exit(1)
}
}
process.on('SIGTERM', shutdown)
process.on('SIGINT', shutdown)
/*
setInterval(() => {
global.gc()
const used = process.memoryUsage()
for (let key in used) {
console.log(`${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`)
}
}, 10000)
*/