...
|
...
|
@@ -33,11 +33,12 @@ class PageCahe extends Model { |
|
|
let queryUriList = queryUris.split('\n');
|
|
|
|
|
|
self._broadcast(`共${queryUriList.length}条规则清理...`);
|
|
|
let keys = [];
|
|
|
for (let i = 0; i < queryUriList.length; i++) {
|
|
|
let queryUri = queryUriList[i];
|
|
|
|
|
|
self._broadcast(`规则${i+1}:${queryUri}`);
|
|
|
let keys = [md5(queryUri)];
|
|
|
// self._broadcast(`规则${i+1}:${queryUri}`);
|
|
|
keys.push(md5(queryUri));
|
|
|
// queryUri = self.replaceUrl(queryUri);
|
|
|
// let sql = `select FIRST(cache_status) from ${storeTableName} where full_path =~ /${queryUri}.*/ group by "key"`;
|
|
|
// let result = await InfluxDB.query(sql);
|
...
|
...
|
@@ -45,16 +46,17 @@ class PageCahe extends Model { |
|
|
// self._broadcast(`未查询到匹配的缓存信息`);
|
|
|
// continue;
|
|
|
// }
|
|
|
let servers = await self.findAll();
|
|
|
|
|
|
}
|
|
|
let servers = await self.findAll();
|
|
|
|
|
|
self._broadcast(`共${servers.length}台nginx准备清理..`)
|
|
|
for (let i = 0; i < servers.length; i++) {
|
|
|
try {
|
|
|
self._broadcast(`第${i+1}台nginx准备清理:`)
|
|
|
await self._removeCache(servers[i], keys, storeTableName);
|
|
|
} catch (err) {
|
|
|
self._broadcast(`错误信息:${err}`)
|
|
|
}
|
|
|
self._broadcast(`共${servers.length}台nginx准备清理..`)
|
|
|
for (let i = 0; i < servers.length; i++) {
|
|
|
try {
|
|
|
self._broadcast(`第${i+1}台nginx准备清理:`)
|
|
|
await self._removeCache(servers[i], keys, storeTableName);
|
|
|
} catch (err) {
|
|
|
self._broadcast(`错误信息:${err}`)
|
|
|
}
|
|
|
}
|
|
|
self._broadcast(`执行完毕`);
|
...
|
...
|
@@ -97,19 +99,20 @@ class PageCahe extends Model { |
|
|
*/
|
|
|
async _removeCache(server, keys, storeTableName) {
|
|
|
let self = this;
|
|
|
let limit = 2;
|
|
|
let limit = 1;
|
|
|
let block = parseInt(keys.length / limit, 10) + (keys.length % limit ? 1 : 0);
|
|
|
let blockIndex = 0;
|
|
|
//连接ssh后执行操作
|
|
|
await self._connStart(async (conn) => {
|
|
|
for (var i = blockIndex; i < block; i++) {
|
|
|
self._broadcast(`正在执行清理,进度:${i+1}/${block}`);
|
|
|
blockIndex = i;
|
|
|
// for (var i = blockIndex; i < block; i++) {
|
|
|
// self._broadcast(`正在执行清理,进度:${i+1}/${block}`);
|
|
|
// blockIndex = i;
|
|
|
// let items = keys.slice(i * limit, i * limit + 2);
|
|
|
// console.log(keys)
|
|
|
let items = keys;
|
|
|
let script = self._joinRemoveScript(server, items, storeTableName);
|
|
|
await self._evalScript(conn, script);
|
|
|
}
|
|
|
// }
|
|
|
}, server)
|
|
|
}
|
|
|
/**
|
...
|
...
|
|