|
@@ -40,11 +40,6 @@ class default_1 {
|
|
|
};
|
|
|
this.finishProcess = (processId) => {
|
|
|
this.client.publish(`twitter:lock/${processId}`, 'DONE');
|
|
|
- this.subscriber.unsubscribe(`twitter:lock/${processId}`, err => {
|
|
|
- if (err)
|
|
|
- return logger.error(`failed to unsubscribe from own process lock, error: ${err}`);
|
|
|
- logger.info(`successfully unsubscribed from process lock ${processId}`);
|
|
|
- });
|
|
|
};
|
|
|
this.waitForProcess = (processId, timeout) => {
|
|
|
if (!(processId in this.subscriptions)) {
|
|
@@ -173,6 +168,21 @@ class default_1 {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ const match = /^twitter:lock\/(.+)$/.exec(channel);
|
|
|
+ if (!match)
|
|
|
+ return;
|
|
|
+ const processId = match[1];
|
|
|
+ if (message === 'DONE')
|
|
|
+ logger.info(`received notification that process ${processId} finished successfully`);
|
|
|
+ if (message === 'BREAK')
|
|
|
+ logger.warn(`received notification that process ${processId} was terminated prematurely`);
|
|
|
+ this.subscriber.unsubscribe(channel, err => {
|
|
|
+ if (err)
|
|
|
+ return logger.error(`failed to unsubscribe from process lock ${processId}, error: ${err}`);
|
|
|
+ logger.info(`successfully unsubscribed from process lock ${processId}`);
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
this.subscriptions = {};
|