This commit is contained in:
chaosBreaking
2019-10-17 11:14:05 +08:00
parent 8b94f641b0
commit a1213adf66

View File

@@ -108,6 +108,7 @@ const mock = {
touch: () => {mylog.info('-----------------\n');},
done: () => {mylog.info('done');},
};
async function mine (job = mock, done = mock) {
//todo: 程序内检查是否可以执行,保证不会启动时错误的自动执行一次
mylog.info('[Schedule Job] 挖矿程序 开始定时计算作业...');
@@ -157,6 +158,7 @@ async function mine (job = mock, done = mock) {
});
}
currentIndex += 10;
probe.currentIndex = currentIndex;
}
mylog.info('收益计算分配完成');
await system.findOneAndUpdate({
@@ -178,7 +180,9 @@ async function mine (job = mock, done = mock) {
typeof done === 'function' && done('收益计算分配完成');
process.exit();
}
const probe = {
currentIndex: 0
};
const start = async () => {
const SysConfig = require('../../configSec');
mongoose.set('useCreateIndex', true);
@@ -196,6 +200,13 @@ const start = async () => {
useFindAndModify: false,
useUnifiedTopology: true
});
const beforeExit = async (msg) => {
mylog.info('意外退出', msg);
mylog.info('进行到第'+ probe.currentIndex + '个用户');
};
process.on('SIGINT', beforeExit);
process.on('uncaughtException', beforeExit);
process.on('unhandledRejection', beforeExit);
mine();
};
start();