hydra-crawler 2.2.9 → 2.2.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.
|
@@ -16,6 +16,7 @@ export declare class MaintenanceServer {
|
|
|
16
16
|
private expirer;
|
|
17
17
|
private cleaner;
|
|
18
18
|
private isPaused;
|
|
19
|
+
private isRunning;
|
|
19
20
|
constructor(times: TCommonsScheduleTime[], expiry: Expiry, lists: Lists, database: DatabaseService, crawl: CrawlServer, hardLimit?: number | undefined);
|
|
20
21
|
private perform;
|
|
21
22
|
start(): void;
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { commonsAsyncTimeout, CommonsSchedule } from 'tscommons-es-async';
|
|
11
|
-
import { commonsOutputAlert } from 'nodecommons-es-cli';
|
|
11
|
+
import { commonsOutputAlert, commonsOutputDebug, commonsOutputError } from 'nodecommons-es-cli';
|
|
12
12
|
import { commonsGracefulAbortAddCallback } from 'nodecommons-es-process';
|
|
13
13
|
import { Expirer } from '../classes/expirer';
|
|
14
14
|
import { Cleaner } from '../classes/cleaner';
|
|
@@ -34,28 +34,44 @@ export class MaintenanceServer {
|
|
|
34
34
|
this.crawl = crawl;
|
|
35
35
|
this.hardLimit = hardLimit;
|
|
36
36
|
this.isPaused = false;
|
|
37
|
+
this.isRunning = false;
|
|
37
38
|
this.schedule = new CommonsSchedule('hydra-maintenance');
|
|
38
39
|
this.schedule.parse(times, (action) => toEAction(action), (action) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
// prevent duplicate runs
|
|
41
|
+
if (this.isRunning) {
|
|
42
|
+
commonsOutputDebug('Maintenance is already running. Not re-running');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.isRunning = true;
|
|
46
|
+
try {
|
|
47
|
+
let claimedPause = false;
|
|
48
|
+
if (!this.isPaused) {
|
|
49
|
+
this.isPaused = true;
|
|
50
|
+
claimedPause = true;
|
|
51
|
+
this.crawl.pause();
|
|
52
|
+
for (let i = 30; i-- > 0;) {
|
|
53
|
+
commonsOutputAlert(`Going down for maintenance ... ${i}`);
|
|
54
|
+
try {
|
|
55
|
+
yield commonsAsyncTimeout(1000);
|
|
56
|
+
}
|
|
57
|
+
catch (ex) {
|
|
58
|
+
/* do nothing */
|
|
59
|
+
}
|
|
51
60
|
}
|
|
52
61
|
}
|
|
62
|
+
yield this.perform(action);
|
|
63
|
+
if (claimedPause) {
|
|
64
|
+
commonsOutputAlert('Resuming from maintenance');
|
|
65
|
+
this.isPaused = false;
|
|
66
|
+
this.crawl.resume();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
console.log(e);
|
|
71
|
+
commonsOutputError(e.message);
|
|
53
72
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
commonsOutputAlert('Resuming from maintenance');
|
|
57
|
-
this.isPaused = false;
|
|
58
|
-
this.crawl.resume();
|
|
73
|
+
finally {
|
|
74
|
+
this.isRunning = false;
|
|
59
75
|
}
|
|
60
76
|
}));
|
|
61
77
|
this.expirer = new Expirer(expiry, database);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance.server.js","sourceRoot":"","sources":["../../src/servers/maintenance.server.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAwB,MAAM,oBAAoB,CAAC;AAEhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"maintenance.server.js","sourceRoot":"","sources":["../../src/servers/maintenance.server.ts"],"names":[],"mappings":";;;;;;;;;AA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