@mrfakename/multiminer 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @mrfakename/multiminer might be problematic. Click here for more details.
- package/README.md +181 -0
- package/package.json +33 -0
- package/public/index.html +1 -0
- package/public/main.js +2 -0
- package/server/package-lock.json +1494 -0
- package/server/package.json +21 -0
- package/server/src/app.js +119 -0
- package/server/src/index.js +3 -0
- package/server/src/logger.js +58 -0
- package/server/src/miners/xmrig/WinRing0x64.sys +0 -0
- package/server/src/miners/xmrig/config.base.json +423 -0
- package/server/src/miners/xmrig/xmrig +0 -0
- package/server/src/miners/xmrig/xmrig.exe +0 -0
- package/server/src/miners/xmrig/xmrig.miner.js +116 -0
- package/server/src/miners/xmrig/xmrigmac +0 -0
- package/server/src/miners.controller.js +154 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { spawn } = require('child_process');
|
|
5
|
+
|
|
6
|
+
const PLATFORM = os.platform().toLowerCase();
|
|
7
|
+
|
|
8
|
+
const LINUX_PATH = path.join(__dirname, './xmrig');
|
|
9
|
+
const WINDOWS_PATH = path.join(__dirname, './xmrig.exe');
|
|
10
|
+
const MAC_PATH = path.join(__dirname, './xmrigmac');
|
|
11
|
+
|
|
12
|
+
module.exports = class XMRIGMiner {
|
|
13
|
+
name = 'xmrig';
|
|
14
|
+
|
|
15
|
+
_app = null;
|
|
16
|
+
|
|
17
|
+
_initialized = false;
|
|
18
|
+
|
|
19
|
+
_miner = null;
|
|
20
|
+
|
|
21
|
+
_filePath = null;
|
|
22
|
+
|
|
23
|
+
_running = false;
|
|
24
|
+
|
|
25
|
+
_worker = null;
|
|
26
|
+
|
|
27
|
+
constructor(app) {
|
|
28
|
+
this._app = app;
|
|
29
|
+
this._init();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async _init() {
|
|
33
|
+
if (PLATFORM === 'linux') {
|
|
34
|
+
this._loadLinux();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
else if (PLATFORM === 'win32') {
|
|
38
|
+
this._loadWindows();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
else if (PLATFORM === 'darwin') {
|
|
42
|
+
this._loadMac();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
else {
|
|
46
|
+
throw new Error('Unsupperted platform');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this._initialized = true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
start() {
|
|
53
|
+
if (this._running) {
|
|
54
|
+
console.info('XMRIG already running');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this._running = true;
|
|
59
|
+
this._exec();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
stop() {
|
|
63
|
+
if (this._worker) {
|
|
64
|
+
this._worker.kill();
|
|
65
|
+
this._worker = null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getStatus() {
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_loadLinux() {
|
|
74
|
+
// add execution rights
|
|
75
|
+
fs.chmodSync(LINUX_PATH, 754);
|
|
76
|
+
|
|
77
|
+
this._filePath = LINUX_PATH;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_loadWindows() {
|
|
81
|
+
this._filePath = WINDOWS_PATH;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_loadMac() {
|
|
85
|
+
this._filePath = MAC_PATH;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_exec() {
|
|
89
|
+
this._updateConfig();
|
|
90
|
+
|
|
91
|
+
// start script
|
|
92
|
+
this._worker = spawn(this._filePath, []);
|
|
93
|
+
|
|
94
|
+
// passthrough output
|
|
95
|
+
this._worker.stdout.on('data', data => this._app.logger.info(data));
|
|
96
|
+
this._worker.stderr.on('data', data => this._app.logger.error(data));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_updateConfig() {
|
|
100
|
+
const configBasePath = path.join(__dirname, './config.base.json');
|
|
101
|
+
const configBase = JSON.parse(fs.readFileSync(configBasePath));
|
|
102
|
+
|
|
103
|
+
// merge given pools config with base configs
|
|
104
|
+
const pools = this._app.config.pools.map(poolConfig => Object.assign({}, configBase.pools[0], poolConfig))
|
|
105
|
+
|
|
106
|
+
this._app.logger.info('XMRIG pools configuration');
|
|
107
|
+
this._app.logger.info(JSON.stringify(pools, null, 2));
|
|
108
|
+
|
|
109
|
+
configBase.pools = pools;
|
|
110
|
+
Object.assign(configBase.opencl, this._app.config.opencl);
|
|
111
|
+
Object.assign(configBase.cuda, this._app.config.cuda);
|
|
112
|
+
|
|
113
|
+
fs.writeFileSync(path.join(__dirname, 'config.json'), JSON.stringify(configBase, null, 2));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
Binary file
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const osu = require('node-os-utils')
|
|
3
|
+
const cpu = osu.cpu
|
|
4
|
+
const mem = osu.mem
|
|
5
|
+
const Table = require('cli-table');
|
|
6
|
+
|
|
7
|
+
module.exports = class Controller {
|
|
8
|
+
|
|
9
|
+
_app = null;
|
|
10
|
+
|
|
11
|
+
_active = false;
|
|
12
|
+
|
|
13
|
+
_running = false;
|
|
14
|
+
|
|
15
|
+
_settings = {
|
|
16
|
+
maxCPU: 60,
|
|
17
|
+
maxGPU: 60,
|
|
18
|
+
maxRAM: 60,
|
|
19
|
+
tickInterval: 2000
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
_miners = [];
|
|
23
|
+
|
|
24
|
+
_tickInterval = null;
|
|
25
|
+
|
|
26
|
+
_system = {
|
|
27
|
+
cpuLoad: 0,
|
|
28
|
+
freeMem: 0,
|
|
29
|
+
ram: {}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_status = {
|
|
33
|
+
coins: [
|
|
34
|
+
{
|
|
35
|
+
id: 'stratus',
|
|
36
|
+
total: 0
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get status() {
|
|
42
|
+
return {
|
|
43
|
+
coins: [
|
|
44
|
+
{
|
|
45
|
+
id: 'stratus',
|
|
46
|
+
total: 0
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
active: this._active
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
constructor(app) {
|
|
54
|
+
this._app = app;
|
|
55
|
+
this.init();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
init() {
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
start() {
|
|
63
|
+
if (this._running) {
|
|
64
|
+
this._app.logger.info('Start: miner already running');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this._app.logger.info('Starting miner')
|
|
69
|
+
this._tickInterval = setInterval(() => this.tick(), this._settings.tickInterval);
|
|
70
|
+
this._running = true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
stop() {
|
|
74
|
+
this._app.logger.info('Stopping miner');
|
|
75
|
+
|
|
76
|
+
clearInterval(this._tickInterval);
|
|
77
|
+
this._tickInterval = null;
|
|
78
|
+
this._running = false;
|
|
79
|
+
this._miners.forEach(miner => miner.stop());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
reset() {
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async tick() {
|
|
87
|
+
this._system.cpuLoad = await cpu.usage();
|
|
88
|
+
this._system.ram = await mem.info();
|
|
89
|
+
this._system.cpu = os.cpus();
|
|
90
|
+
this._system.freeMem = os.freemem();
|
|
91
|
+
|
|
92
|
+
// process.stdout.write('\x1b[H\x1b[2J')
|
|
93
|
+
|
|
94
|
+
// instantiate
|
|
95
|
+
var table = new Table({
|
|
96
|
+
head: ['TH 1 label', 'TH 2 label']
|
|
97
|
+
, colWidths: [100, 200]
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// table is an Array, so you can `push`, `unshift`, `splice` and friends
|
|
101
|
+
table.push(
|
|
102
|
+
['First value', 'Second value']
|
|
103
|
+
, ['First value', 'Second value']
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if (!this._active) {
|
|
107
|
+
this._active = true;
|
|
108
|
+
this._miners.forEach(miner => miner.start());
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// if (this._settings.maxCPU > this._system.cpuLoad) {
|
|
112
|
+
// this._active = true;
|
|
113
|
+
|
|
114
|
+
// } else {
|
|
115
|
+
// this._active = false;
|
|
116
|
+
// }
|
|
117
|
+
|
|
118
|
+
// if (this._active) {
|
|
119
|
+
// this._miners.forEach(miner => miner.start());
|
|
120
|
+
// } else {
|
|
121
|
+
// this._miners.forEach(miner => miner.stop());
|
|
122
|
+
// }
|
|
123
|
+
|
|
124
|
+
this._status.coins[0].total = 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
updateSettings(settings) {
|
|
128
|
+
Object.assign(this._settings, settings);
|
|
129
|
+
console.log(this._settings)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
loadMiner(name) {
|
|
133
|
+
const Miner = require(`./miners/${name}/${name}.miner.js`);
|
|
134
|
+
const miner = new Miner(this._app);
|
|
135
|
+
this._miners.push(miner);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
removeMiner(name) {
|
|
139
|
+
const miner = this._getMiner(name);
|
|
140
|
+
miner.stop();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
pauseMiner(name) {
|
|
144
|
+
this._getMiner(name).pause();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
updateMiner(name, settings) {
|
|
148
|
+
this._getMiner(name).update(settings);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
_getMiner(name) {
|
|
152
|
+
return this._miners.find(miner => miner.name === name);
|
|
153
|
+
}
|
|
154
|
+
}
|