q-koa 13.1.3 → 13.1.4
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/core/app.js
CHANGED
|
@@ -10,6 +10,7 @@ const moment = require('moment')
|
|
|
10
10
|
const { EventEmitter } = require('events')
|
|
11
11
|
const nodeVm = require('vm')
|
|
12
12
|
const LRU = require('lru-cache')
|
|
13
|
+
const axios = require('axios')
|
|
13
14
|
|
|
14
15
|
const { Serve } = require('static-koa-router')
|
|
15
16
|
|
|
@@ -426,7 +427,8 @@ class APP {
|
|
|
426
427
|
subscriber,
|
|
427
428
|
appConfig: _.defaultsDeep(
|
|
428
429
|
configExist ? require(path.resolve(__dirname, configPath)) : {},
|
|
429
|
-
this.config.app
|
|
430
|
+
this.config.app,
|
|
431
|
+
{ appName, ip: this.config.ip, port: this.port }
|
|
430
432
|
),
|
|
431
433
|
}
|
|
432
434
|
} else {
|
|
@@ -434,7 +436,8 @@ class APP {
|
|
|
434
436
|
sequelize: db,
|
|
435
437
|
appConfig: _.defaultsDeep(
|
|
436
438
|
configExist ? require(path.resolve(__dirname, configPath)) : {},
|
|
437
|
-
this.config.app
|
|
439
|
+
this.config.app,
|
|
440
|
+
{ appName, ip: this.config.ip, port: this.port }
|
|
438
441
|
),
|
|
439
442
|
}
|
|
440
443
|
}
|
|
@@ -2211,6 +2214,26 @@ APP.getConfig = (app) => ({
|
|
|
2211
2214
|
app.redisClient.publish('cache clear', target)
|
|
2212
2215
|
} else {
|
|
2213
2216
|
app.cache.set(target, null)
|
|
2217
|
+
|
|
2218
|
+
if (app.appConfig.appName) {
|
|
2219
|
+
const ipHost = (
|
|
2220
|
+
Array.isArray(app.appConfig.productionHost)
|
|
2221
|
+
? app.appConfig.productionHost
|
|
2222
|
+
: [app.appConfig.productionHost]
|
|
2223
|
+
).filter((url) => {
|
|
2224
|
+
return url.match(
|
|
2225
|
+
/^(http:\/\/|https:\/\/)?(\d{1,3}\.){3}\d{1,3}:\d{1,5}/
|
|
2226
|
+
)
|
|
2227
|
+
})
|
|
2228
|
+
|
|
2229
|
+
Promise.all(
|
|
2230
|
+
ipHost.map((host) => {
|
|
2231
|
+
return axios
|
|
2232
|
+
.get(`${host}/${app.appConfig.appName}/cache/clear?key=${target}`)
|
|
2233
|
+
.then((res) => res.data)
|
|
2234
|
+
})
|
|
2235
|
+
)
|
|
2236
|
+
}
|
|
2214
2237
|
}
|
|
2215
2238
|
},
|
|
2216
2239
|
})
|
|
@@ -72,9 +72,15 @@ exports.initModel = async (ctx) => {
|
|
|
72
72
|
return ctx.ERROR('请检查,model为空')
|
|
73
73
|
}
|
|
74
74
|
if (app.appConfig.productionHost) {
|
|
75
|
-
const productionHost =
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
const productionHost = (
|
|
76
|
+
Array.isArray(app.appConfig.productionHost)
|
|
77
|
+
? app.appConfig.productionHost
|
|
78
|
+
: [app.appConfig.productionHost]
|
|
79
|
+
).filter((url) => {
|
|
80
|
+
return !url.match(
|
|
81
|
+
/^(http:\/\/|https:\/\/)?(\d{1,3}\.){3}\d{1,3}:\d{1,5}/
|
|
82
|
+
)
|
|
83
|
+
})
|
|
78
84
|
|
|
79
85
|
for (const host of productionHost) {
|
|
80
86
|
const { code, data: productionModel } = await axios
|