未显示 nuxt ssr 应用程序的服务器端日志
Logs on server side for nuxt ssr app not appear
嘿,我正在尝试将我的缓存转换为使用 Redis。
我创建了从 AWS 获取我的秘密并更新的模块
store.host 和 store.auth_pass.
我正在使用 ECS 运行 我的服务器,在将我的更改提交到服务器之后,对域的每个请求都被卡住,直到出现 504。
我不知道进程的哪一部分被卡住了 我服务器端的所有日志都没有出现在我的云手表中,当我尝试使用 vs 调试服务器时,它们仅在我通过终端 运行 时出现.
我的模块init-redis
// Create a Secrets Manager client
const client = new AWS.SecretsManager({
region: region });
// In this sample we only handle the specific exceptions for the 'GetSecretValue' API.
// See https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html
// We rethrow the exception by default.
try {
const data = await client.getSecretValue({ SecretId: secretName }).promise();
if ("SecretString" in data) {
secret = data.SecretString;
secret = JSON.parse(secret);
this.options.cache.store.auth_pass = secret.password;
this.options.cache.store.host = secret.host;
}
console.log(`${data}`);
} catch (err) {
console.error(err);
}
我的 nuxt 配置模块部分:
modules: [
"@nuxtjs/style-resources",
"@nuxtjs/svg",
"nuxt-i18n",
"@nuxtjs/firebase",
"@nuxtjs/redirect-module",
"@nuxtjs/sentry",
"~/modules/init-redis",
"nuxt-ssr-cache"
],
cache: {
// if you're serving multiple host names (with differing
// results) from the same server, set this option to true.
// (cache keys will be prefixed by your host name)
// if your server is behind a reverse-proxy, please use
// express or whatever else that uses 'X-Forwarded-Host'
// header field to provide req.hostname (actual host name)
useHostPrefix: false,
pages: ["/"],
key(route, context) {
return route;
},
store: {
type: "redis",
host: "localhost",
auth_pass: "XXXXX",
// maximum number of pages to store in memory
// if limit is reached, least recently used page
// is removed.
max: 1000,
// number of seconds to store this page in cache
ttl: 15,
configure: [
["maxmemory", "500mb"],
["maxmemory-policy", "allkeys-lru"]
]
}
},
AWS Redis 与 SSL 通信,所以我不得不将我的代码更改为这种方式:
this.options.cache.store.url = `rediss://default:${secret.password}@${secret.host}:6379`;
嘿,我正在尝试将我的缓存转换为使用 Redis。
我创建了从 AWS 获取我的秘密并更新的模块
store.host 和 store.auth_pass.
我正在使用 ECS 运行 我的服务器,在将我的更改提交到服务器之后,对域的每个请求都被卡住,直到出现 504。
我不知道进程的哪一部分被卡住了 我服务器端的所有日志都没有出现在我的云手表中,当我尝试使用 vs 调试服务器时,它们仅在我通过终端 运行 时出现.
我的模块init-redis
// Create a Secrets Manager client
const client = new AWS.SecretsManager({
region: region });
// In this sample we only handle the specific exceptions for the 'GetSecretValue' API.
// See https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html
// We rethrow the exception by default.
try {
const data = await client.getSecretValue({ SecretId: secretName }).promise();
if ("SecretString" in data) {
secret = data.SecretString;
secret = JSON.parse(secret);
this.options.cache.store.auth_pass = secret.password;
this.options.cache.store.host = secret.host;
}
console.log(`${data}`);
} catch (err) {
console.error(err);
}
我的 nuxt 配置模块部分:
modules: [
"@nuxtjs/style-resources",
"@nuxtjs/svg",
"nuxt-i18n",
"@nuxtjs/firebase",
"@nuxtjs/redirect-module",
"@nuxtjs/sentry",
"~/modules/init-redis",
"nuxt-ssr-cache"
],
cache: {
// if you're serving multiple host names (with differing
// results) from the same server, set this option to true.
// (cache keys will be prefixed by your host name)
// if your server is behind a reverse-proxy, please use
// express or whatever else that uses 'X-Forwarded-Host'
// header field to provide req.hostname (actual host name)
useHostPrefix: false,
pages: ["/"],
key(route, context) {
return route;
},
store: {
type: "redis",
host: "localhost",
auth_pass: "XXXXX",
// maximum number of pages to store in memory
// if limit is reached, least recently used page
// is removed.
max: 1000,
// number of seconds to store this page in cache
ttl: 15,
configure: [
["maxmemory", "500mb"],
["maxmemory-policy", "allkeys-lru"]
]
}
},
AWS Redis 与 SSL 通信,所以我不得不将我的代码更改为这种方式:
this.options.cache.store.url = `rediss://default:${secret.password}@${secret.host}:6379`;