Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
5fb5979c91 | |||
cf61de9093 | |||
cf7c3cb910 | |||
b8eb82de12 | |||
8c01d5cabf | |||
1eef97ee9a | |||
45544fffd0 | |||
f227eaee37 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@mojoio/bobcat",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.12",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@mojoio/bobcat",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.12",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartnetwork": "^2.0.14",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/bobcat",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.12",
|
||||
"private": false,
|
||||
"description": "a module to talk to bobcat miners",
|
||||
"main": "dist_ts/index.js",
|
||||
|
@ -8,11 +8,16 @@ import * as bobcat from '../ts/index';
|
||||
let testBobcatManager: bobcat.BobcatManager;
|
||||
let testBobcat: bobcat.Bobcat;
|
||||
|
||||
tap.test('first test', async () => {
|
||||
tap.test('should create a bobcat manager', async () => {
|
||||
testBobcatManager = new bobcat.BobcatManager();
|
||||
expect(testBobcatManager).toBeInstanceOf(bobcat.BobcatManager);
|
||||
});
|
||||
|
||||
tap.test('should create a bobcat', async () => {
|
||||
testBobcat = new bobcat.Bobcat('bobcat.bleu.de');
|
||||
expect(testBobcat).toBeInstanceOf(bobcat.Bobcat);
|
||||
})
|
||||
|
||||
tap.test('should add a Bobcat miner', async () => {
|
||||
const bobcatAddresses = testQenv.getEnvVarOnDemand('BOBCATS').split(',');
|
||||
console.log(bobcatAddresses);
|
||||
@ -22,9 +27,8 @@ tap.test('should add a Bobcat miner', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
tap.test('', async () => {
|
||||
testBobcat = new bobcat.Bobcat('bobcat.bleu.de');
|
||||
expect(testBobcat).toBeInstanceOf(bobcat.Bobcat);
|
||||
tap.test('should run maintenance on bobcats', async () => {
|
||||
await testBobcatManager.runMaintenance();
|
||||
})
|
||||
|
||||
tap.start();
|
||||
|
@ -8,8 +8,12 @@ export class Bobcat {
|
||||
// STATIC
|
||||
public static async createFromNetworkAddress(networkAddressArg: string) {
|
||||
const newBobcat = new Bobcat(networkAddressArg);
|
||||
await newBobcat.gatherMinerDetails();
|
||||
await newBobcat.checkMinerStatus();
|
||||
try {
|
||||
await newBobcat.checkMinerStatus();
|
||||
await newBobcat.gatherMinerDetails();
|
||||
} catch(err) {
|
||||
console.log('initial adding completed with errors');
|
||||
}
|
||||
return newBobcat;
|
||||
}
|
||||
|
||||
@ -41,4 +45,26 @@ export class Bobcat {
|
||||
this.latestMinerDetails = body;
|
||||
return this.latestMinerDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* runs maintenance on the bobcat
|
||||
*/
|
||||
public async runMaintenance() {
|
||||
await this.checkMinerStatus();
|
||||
await this.gatherMinerDetails();
|
||||
if (this.latestStatus.status !== 'Synced') {
|
||||
console.log(`Miner ${this.latestMinerDetails.animal} is not synced. Restarting now!`);
|
||||
await this.restart().catch();
|
||||
}
|
||||
}
|
||||
|
||||
public async restart() {
|
||||
const response = await plugins.smartrequest.request(`http://${this.networkAddress}/admin/reboot`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: 'Basic ' + Buffer.from('bobcat:miner').toString('base64')
|
||||
}
|
||||
});
|
||||
console.log(response.statusCode);
|
||||
}
|
||||
}
|
@ -11,4 +11,14 @@ export class BobcatManager {
|
||||
const newBobcat = await Bobcat.createFromNetworkAddress(networkAddressArg);
|
||||
this.bobcats.push(newBobcat);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs the maintenance on all managed bobcats
|
||||
*/
|
||||
public async runMaintenance() {
|
||||
console.log(`now running maintenance on ${this.bobcats.length} bobcats!`);
|
||||
for (const bobcat of this.bobcats) {
|
||||
await bobcat.runMaintenance();
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user