6 Commits

Author SHA1 Message Date
efa5982dc9 1.0.20 2022-02-27 22:36:18 +01:00
db8f587d8d fix(core): update 2022-02-27 22:36:17 +01:00
cbc3334994 1.0.19 2022-02-27 21:57:01 +01:00
d111e3709b fix(core): update 2022-02-27 21:57:00 +01:00
66a8610bb1 1.0.18 2022-02-27 21:43:15 +01:00
e4c41b82ef 1.0.17 2022-02-27 21:33:55 +01:00
4 changed files with 10 additions and 10 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@mojoio/bobcat", "name": "@mojoio/bobcat",
"version": "1.0.16", "version": "1.0.20",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@mojoio/bobcat", "name": "@mojoio/bobcat",
"version": "1.0.16", "version": "1.0.20",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartdelay": "^2.0.13",

View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/bobcat", "name": "@mojoio/bobcat",
"version": "1.0.16", "version": "1.0.20",
"private": false, "private": false,
"description": "a module to talk to bobcat miners", "description": "a module to talk to bobcat miners",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

@ -38,7 +38,7 @@ export class Bobcat {
*/ */
public async checkMinerStatus () { public async checkMinerStatus () {
const response = await plugins.smartrequest.getJson(`http://${this.networkAddress}/status.json`, { const response = await plugins.smartrequest.getJson(`http://${this.networkAddress}/status.json`, {
timeout: 30000 timeout: 60000
}); });
const body: interfaces.IMinerStatus = response.body; const body: interfaces.IMinerStatus = response.body;
this.latestStatus = body; this.latestStatus = body;
@ -50,7 +50,7 @@ export class Bobcat {
*/ */
public async gatherMinerDetails () { public async gatherMinerDetails () {
const response = await plugins.smartrequest.getJson(`http://${this.networkAddress}/miner.json`, { const response = await plugins.smartrequest.getJson(`http://${this.networkAddress}/miner.json`, {
timeout: 30000 timeout: 60000
}); });
const body: interfaces.IMinerDetailsResponse = response.body; const body: interfaces.IMinerDetailsResponse = response.body;
this.latestMinerDetails = body; this.latestMinerDetails = body;
@ -61,8 +61,8 @@ export class Bobcat {
* runs maintenance on the bobcat * runs maintenance on the bobcat
*/ */
public async runMaintenance () { public async runMaintenance () {
await this.checkMinerStatus(); await plugins.smartpromise.timeoutAndContinue(this.checkMinerStatus());
await this.gatherMinerDetails(); await plugins.smartpromise.timeoutAndContinue(this.gatherMinerDetails());
if (this.latestStatus.status === 'Synced' && parseInt(this.latestStatus.gap) > -50 && parseInt(this.latestStatus.gap) < 50) { if (this.latestStatus.status === 'Synced' && parseInt(this.latestStatus.gap) > -50 && parseInt(this.latestStatus.gap) < 50) {
console.log(`Miner ${this.latestMinerDetails.animal} at ${this.networkAddress} is Synced. ok!`) console.log(`Miner ${this.latestMinerDetails.animal} at ${this.networkAddress} is Synced. ok!`)
return; return;
@ -103,7 +103,7 @@ export class Bobcat {
await plugins.smartdelay.delayFor(10000); await plugins.smartdelay.delayFor(10000);
const response = await plugins.smartrequest.request(`http://${this.networkAddress}/admin/reboot`, { const response = await plugins.smartrequest.request(`http://${this.networkAddress}/admin/reboot`, {
method: 'POST', method: 'POST',
timeout: 30000, timeout: 60000,
...Bobcat.minerAuthObject ...Bobcat.minerAuthObject
}); });
console.log(response.statusCode); console.log(response.statusCode);

View File

@ -33,7 +33,7 @@ export class BobcatManager {
public async addBobcat (networkAddressArg: string) { public async addBobcat (networkAddressArg: string) {
const newBobcat = await Bobcat.createFromNetworkAddress(networkAddressArg); const newBobcat = await Bobcat.createFromNetworkAddress(networkAddressArg);
this.bobcats.push(newBobcat); this.bobcats.push(newBobcat);
console.log(`added ${newBobcat.latestMinerDetails.animal} at ${newBobcat.networkAddress}`); console.log(`added ${newBobcat.latestMinerDetails?.animal} at ${newBobcat.networkAddress}`);
} }
/** /**
@ -44,7 +44,7 @@ export class BobcatManager {
console.log(`cooling down for 10 seconds`); console.log(`cooling down for 10 seconds`);
await plugins.smartdelay.delayFor(10000); await plugins.smartdelay.delayFor(10000);
for (const bobcat of this.bobcats) { for (const bobcat of this.bobcats) {
console.log(`now running maintenance on ${bobcat.latestMinerDetails.animal} at ${bobcat.networkAddress}`); console.log(`now running maintenance on ${bobcat.latestMinerDetails?.animal} at ${bobcat.networkAddress}`);
await plugins.smartpromise.timeoutAndContinue(bobcat.runMaintenance()); await plugins.smartpromise.timeoutAndContinue(bobcat.runMaintenance());
} }
}; };