-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
23 lines (20 loc) · 742 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const addon = require("node-gyp-build")(__dirname);
let watchdogTimeout = null;
module.exports = {
addon,
ready: (pid = process.pid) => addon.ready(pid),
stopping: (pid = process.pid) => addon.stopping(pid),
status: (msg = '') => addon.status(`STATUS=${msg}\n`),
watchdog: () => addon.watchdog(),
watchdogInterval: () => addon.watchdogInterval(),
startWatchdogMode: (interval) => {
interval = +interval
if (interval <= 0) throw new RangeError('interval must be a positive number')
watchdogTimeout && clearInterval(watchdogTimeout)
watchdogTimeout = setInterval(addon.watchdog, interval)
},
stopWatchdogMode: () => {
watchdogTimeout && clearInterval(watchdogTimeout)
watchdogTimeout = null
},
};