Skip to content

Commit

Permalink
Merge 48a563c into f8c88f5
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Jun 10, 2020
2 parents f8c88f5 + 48a563c commit 90e2de5
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions api/hooks/sdtdLogs/LoggingObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,30 @@ class LoggingObject extends EventEmitter {
});
}

async addFetchJob() {
this.queue.add(
{
serverId: this.serverId,
lastLogLine: this.lastLogLine // FIXME - currently ignored
},
{
timeout: 5000,
removeOnComplete: 100,
removeOnFail: 100,
attempts: 1,
delay: this.intervalTime
}
);
};

async init(ms = sails.config.custom.logCheckInterval) {

if (!ms) {
ms = 3000;
}

this.intervalTime = ms;

// Make sure there are no lingering jobs
await this.stop();

Expand All @@ -52,22 +70,8 @@ class LoggingObject extends EventEmitter {
} catch (error) {
// Fail silently
}
const addFetchJob = async () => {
this.queue.add(
{
serverId: this.serverId,
lastLogLine: this.lastLogLine // FIXME - currently ignored
},
{
timeout: 10000,
removeOnComplete: true,
removeOnFail: true,
attempts: 1
}
);
};
this.interval = setInterval(addFetchJob, ms);
await addFetchJob()

await this.addFetchJob()
}

async handleError(error) {
Expand All @@ -78,6 +82,7 @@ class LoggingObject extends EventEmitter {
// A job failed with reason `err`!
sails.log.error(`Queue error: ${inspect(err)}`);
await this._failedHandler();
await this.addFetchJob();
return;
}

Expand Down Expand Up @@ -123,7 +128,7 @@ class LoggingObject extends EventEmitter {
}

await this.setFailedToZero();
//await this.setLastLogLine();
await this.addFetchJob();
}

async destroy() {
Expand Down Expand Up @@ -171,7 +176,7 @@ class LoggingObject extends EventEmitter {
`sdtdserver:${this.serverId}:sdtdLogs:lastSuccess`
);
lastSuccess = parseInt(lastSuccess);
if (counter > 100) {
if (counter > 25) {
let prettyLastSuccess = new Date(lastSuccess);

if (!this.slowmode) {
Expand Down

0 comments on commit 90e2de5

Please sign in to comment.