2018-07-01 15:37:59 -07:00
|
|
|
import Base from '@uci/base'
|
|
|
|
|
2018-07-31 10:05:13 -07:00
|
|
|
// const HOST = 'localhost'
|
|
|
|
const HOST = 'sbc'
|
2018-07-01 15:37:59 -07:00
|
|
|
const PORT = 9024
|
|
|
|
let processor = new Base({sockets:'inter#c>t', inter:{host:HOST, port:PORT}, id:'interrupt-processor', useRootNS:true})
|
|
|
|
|
|
|
|
processor.interrupt = async function (packet) {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
console.log('interrupt occured')
|
|
|
|
console.dir(packet)
|
|
|
|
resolve({status: 'processed'})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
processor.reply = async function (packet) {
|
|
|
|
return new Promise((resolve) => {
|
2018-07-31 10:05:13 -07:00
|
|
|
|
|
|
|
console.log('reply from interrupt with packet')
|
2018-07-01 15:37:59 -07:00
|
|
|
console.dir(packet)
|
|
|
|
resolve({status: 'processed'})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
;
|
|
|
|
(async () => {
|
|
|
|
|
|
|
|
await processor.init()
|
2018-07-31 10:05:13 -07:00
|
|
|
console.log('====sending fire command to interrupt===')
|
2018-07-01 15:37:59 -07:00
|
|
|
await processor.send({cmd: 'fire'})
|
2018-07-31 10:05:13 -07:00
|
|
|
console.log('====sending fire command to interrupt===')
|
2018-07-01 15:37:59 -07:00
|
|
|
await processor.send({cmd: 'fire'})
|
|
|
|
// process.kill(process.pid, 'SIGTERM')
|
|
|
|
|
|
|
|
})().catch(err => {
|
|
|
|
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
|
|
|
|
})
|