fully working control example with interrupts
parent
4485f981a5
commit
efd1834d14
|
@ -27,7 +27,10 @@ class Interrupt extends EventEmitter {
|
|||
this.dbt = opts.debounce ? opts.debounce : 200
|
||||
this.poller = new Epoll(
|
||||
debounce((err, fd, events) => {
|
||||
if (err) { this.emit('error', err) } else { this.clear().then(this.emit('fired', this.hook)) }
|
||||
if (err) { this.emit('error', err) } else {
|
||||
// this.clear().then(this.emit('fired', this.hook))
|
||||
this.emit('fired', this.hook)
|
||||
}
|
||||
}, this.dbt, true) // true = leading
|
||||
)
|
||||
}
|
||||
|
@ -36,6 +39,7 @@ class Interrupt extends EventEmitter {
|
|||
|
||||
process.on('SIGINT', () => {
|
||||
this.exit().then((resp) => console.log("\n", resp)) // unexport on cntrl-c
|
||||
.catch(err => console.log("error:", err))
|
||||
})
|
||||
|
||||
return _.pSeries([
|
||||
|
@ -81,7 +85,11 @@ class Interrupt extends EventEmitter {
|
|||
}
|
||||
|
||||
start() {
|
||||
this.clear().then(() => this.poller.add(this.valuefd, Epoll.EPOLLPRI));
|
||||
this.clear().then(() => this.poller.add(this.valuefd, Epoll.EPOLLPRI | Epoll.EPOLLONESHOT));
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.clear().then(() => this.poller.modify(this.valuefd, Epoll.EPOLLPRI | Epoll.EPOLLONESHOT));
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
|
Loading…
Reference in New Issue