36 lines
963 B
JavaScript
36 lines
963 B
JavaScript
|
import Interrupt from '../src/interrupt'
|
||
|
import Base from '@uci/base'
|
||
|
|
||
|
// let interrupt = new Interrupt(24,{id:'test-interrupt', wait:0})
|
||
|
// let listener = new Base({sockets:'inter#s>n', inter:{path:'interrupt:24'}, id:'listener'})
|
||
|
|
||
|
let interrupt = new Interrupt(24,{id:'test-interrupt', wait:0, host:'localhost', hook:true})
|
||
|
let listener = new Base({sockets:'inter#s>t', inter:{port:9024}, id:'listener'})
|
||
|
|
||
|
|
||
|
listener.interrupt = async function (packet) {
|
||
|
return new Promise((resolve) => {
|
||
|
console.log('interrupt socket listener got')
|
||
|
console.dir(packet)
|
||
|
resolve({status: 'processed'})
|
||
|
})
|
||
|
|
||
|
}
|
||
|
|
||
|
;
|
||
|
(async () => {
|
||
|
|
||
|
console.log(await listener.init())
|
||
|
await interrupt.init()
|
||
|
interrupt.fire()
|
||
|
// interrupt.fire()
|
||
|
// interrupt.fire()
|
||
|
// 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')
|
||
|
})
|