amqplib-init 1.1.7 → 1.1.8
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/index.js +4 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -87,11 +87,11 @@ module.exports = {
|
|
|
87
87
|
setInterval(async () => {
|
|
88
88
|
try {
|
|
89
89
|
const { messageCount } = await channel.checkQueue(channelName);
|
|
90
|
-
const
|
|
91
|
-
log.log(`MQ队列中有 ${messageCount}
|
|
92
|
-
if (messageCount === 0 &&
|
|
90
|
+
const hookResult = await queryHook()
|
|
91
|
+
log.log(`MQ队列中有 ${messageCount} 条消息,检测是否可以重启: ${hookResult?1:0}`);
|
|
92
|
+
if (messageCount === 0 && hookResult) {
|
|
93
93
|
log.log('队列中没有消息,正在重载服务...');
|
|
94
|
-
shelljs
|
|
94
|
+
shelljs?.exec(`pm2 reload ${pmId}`); // 使用PM2重载服务
|
|
95
95
|
}
|
|
96
96
|
} catch (e) {
|
|
97
97
|
log.error('检查队列长度时出错:', e);
|