-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (51 loc) · 1.64 KB
/
index.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"use strict";
const co = require('co');
const main = require('./lib/main.js');
const duniter = require('duniter');
/****************************************
* TECHNICAL CONFIGURATION
***************************************/
// Default Duniter node's database
const DEFAULT_DUNITER_DATA_FOLDER = 'rml9-currency-monit';
// host on which UI is available
const DEFAULT_HOST = 'localhost';
// port on which UI is available
const DEFAULT_PORT = 10500;
/****************************************
* SPECIALIZATION
***************************************/
const stack = duniter.statics.autoStack([{
name: 'currency-monit',
required: {
duniter: {
cli: [{
name: 'currency-monit [host] [port]',
desc: 'Starts specialized node currency-monit',
// Disables Duniter node's logs
logs: false,
onDatabaseExecute: (server, conf, program, params, startServices) => co(function*() {
// currency-monit parameters
const SERVER_HOST = params[0] || DEFAULT_HOST;
const SERVER_PORT = parseInt(params[1]) || DEFAULT_PORT;
// IMPORTANT: release Duniter services from "sleep" mode
yield startServices();
// Main Loop
yield main(server, SERVER_HOST, SERVER_PORT);
// Wait forever, this is a permanent program
yield new Promise(() => null);
})
}]
}
}
}]);
co(function*() {
if (!process.argv.includes('--mdb')) {
// We use the default database
process.argv.push('--mdb');
process.argv.push(DEFAULT_DUNITER_DATA_FOLDER);
}
// Execute our program
yield stack.executeStack(process.argv);
// End
process.exit();
});