uci-interrupt/examples/single.js

28 lines
817 B
JavaScript
Raw Normal View History

import Interrupt from '../src/interrupt'
// const delay = time => new Promise(res=>setTimeout(()=>res(),time))
let interrupt = new Interrupt(24,{id:'test-interrupt', wait:0, hook:true, useRootNS:true})
;
(async () => {
await interrupt.init()
console.log('interrupt ready and waiting')
console.log('manual fire of interrupt via interrupt instance')
interrupt.fire()
console.log('manual fire of interrupt via interrupt instance after changing hook')
interrupt.hook = (packet) => {
packet.data='some hook added data'
console.log('custom hook function modifies', packet)
return packet
}
interrupt.fire()
// await delay(3000)
// process.kill(process.pid, 'SIGTERM')
})().catch(err => {
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
process.kill(process.pid, 'SIGTERM')
})