forked from Adamant-im/adamant-coinoptimus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (30 loc) · 1.13 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const notify = require('./helpers/notify');
const db = require('./modules/DB');
const checker = require('./modules/checkerTransactions');
const doClearDB = process.argv.includes('clear_db');
const config = require('./modules/configReader');
const txParser = require('./modules/incomingTxsParser');
// Socket connection
const api = require('./modules/api');
api.socket.initSocket({ socket: config.socket, wsType: config.ws_type, onNewMessage: txParser, admAddress: config.address });
setTimeout(init, 5000);
function init() {
require('./server');
try {
if (doClearDB) {
console.log('Clearing database…');
db.systemDb.db.drop();
db.incomingTxsDb.db.drop();
db.ordersDb.db.drop();
notify(`*${config.notifyName}: database cleared*. Manually stop the Bot now.`, 'info');
} else {
checker();
require('./trade/co_ladder').run();
require('./trade/co_test').test();
notify(`*${config.notifyName} started* for address _${config.address}_ (ver. ${config.version}).`, 'info');
}
} catch (e) {
notify(`${config.notifyName} is not started. Error: ${e}`, 'error');
process.exit(1);
}
}