25 lines
621 B
JavaScript
25 lines
621 B
JavaScript
'use strict';
|
|
|
|
const ps = require('./pubsub.js');
|
|
const {Torrent} = require('>/models');
|
|
|
|
console.log('here!!!!!!!!!!!!!')
|
|
|
|
let statusLock = false;
|
|
setInterval(async function(){
|
|
if(statusLock) return;
|
|
statusLock = true;
|
|
try{
|
|
ps.publish('torrent:server:status', await Torrent.trClient.sessionStats());
|
|
}catch(error){
|
|
ps.publish('torrent:server:status:down')
|
|
// if(error.code === 'ECONNREFUSED') throw new Error('TorrentGatewayDown');
|
|
// console.error('status interval error', error)
|
|
}
|
|
statusLock = false
|
|
}, 10000, statusLock);
|
|
|
|
|
|
// ps.subscribe(/./g, function(...args){
|
|
// console.log('event', args);
|
|
// });
|