vona-module-a-worker 5.0.21 → 5.0.22
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.
- package/dist/bean/bean.worker.d.ts +2 -2
- package/dist/index.js +11 -16
- package/package.json +1 -1
|
@@ -4,8 +4,8 @@ export declare class BeanWorker extends BeanBase {
|
|
|
4
4
|
setAlive(id?: string): Promise<void>;
|
|
5
5
|
delAlive(id?: string): Promise<void>;
|
|
6
6
|
getAlive(id?: string): Promise<boolean | null | undefined>;
|
|
7
|
-
exit(code?: number | string | null | undefined):
|
|
8
|
-
exitAll(code?: number | string | null | undefined):
|
|
7
|
+
exit(code?: number | string | null | undefined): void;
|
|
8
|
+
exitAll(code?: number | string | null | undefined): void;
|
|
9
9
|
reload(): void;
|
|
10
10
|
reloadAll(): void;
|
|
11
11
|
}
|
package/dist/index.js
CHANGED
|
@@ -30,11 +30,12 @@ let BeanWorker = (_dec$4 = Bean(), _dec2$4 = BeanInfo({
|
|
|
30
30
|
if (isNil(id) || id === this.id) return true;
|
|
31
31
|
return await this.scope.cacheRedis.workerAlive.get(id ?? this.id);
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
exit(code) {
|
|
34
|
+
closeApp(false).then(() => {
|
|
35
|
+
process.exit(code);
|
|
36
|
+
});
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
exitAll(code) {
|
|
38
39
|
this.scope.broadcast.exitAll.emit({
|
|
39
40
|
code
|
|
40
41
|
});
|
|
@@ -42,20 +43,14 @@ let BeanWorker = (_dec$4 = Bean(), _dec2$4 = BeanInfo({
|
|
|
42
43
|
reload() {
|
|
43
44
|
const worker = cluster.worker;
|
|
44
45
|
if (!worker) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
this.exit(); // pm2 or forever
|
|
47
|
+
} else {
|
|
48
|
+
closeApp(false).then(() => {
|
|
49
|
+
worker.send('reload-worker');
|
|
50
|
+
});
|
|
48
51
|
}
|
|
49
|
-
closeApp(false).then(() => {
|
|
50
|
-
worker.send('reload-worker');
|
|
51
|
-
});
|
|
52
52
|
}
|
|
53
53
|
reloadAll() {
|
|
54
|
-
if (!cluster.worker) {
|
|
55
|
-
return;
|
|
56
|
-
// maybe throw uncaughtException
|
|
57
|
-
// throw new Error('Only take affect in cluster');
|
|
58
|
-
}
|
|
59
54
|
this.scope.broadcast.reloadAll.emit();
|
|
60
55
|
}
|
|
61
56
|
}) || _class$4) || _class$4);
|
|
@@ -67,7 +62,7 @@ let BroadcastExitAll = (_dec$3 = Broadcast({
|
|
|
67
62
|
module: "a-worker"
|
|
68
63
|
}), _dec$3(_class$3 = _dec2$3(_class$3 = class BroadcastExitAll extends BeanBroadcastBase {
|
|
69
64
|
async execute(data, _isEmitter) {
|
|
70
|
-
|
|
65
|
+
this.bean.worker.exit(data.code);
|
|
71
66
|
}
|
|
72
67
|
}) || _class$3) || _class$3);
|
|
73
68
|
|