小编Jax*_*Jax的帖子

使用 pm2 运行服务器时如何轮换日志文件?

我们使用节点模块 pm2 来运行服务器并捕获应用程序日志。

但由于流量非常巨大,大量数据被存储在单个文件中,大约超过 100Gb。

我们是否有可能在不重新启动服务器的情况下每 1 小时或每 1Gb 文件更改一次文件?

目前我们正在手动执行此操作,重新启动服务器并重命名造成问题的现有文件。

logging pm2 pm2-logrotate nodejs-server

10
推荐指数
2
解决办法
1万
查看次数

在nodejs中使用异步函数时无法返回值

尝试在谷歌云函数中的以下异步函数中调用谷歌api后返回值

 async function getGoogleApiToken() {
      let jwtClient = new google.auth.JWT(
               privatekey.client_email,
               null,
               privatekey.private_key,
               ['https://www.googleapis.com/auth/compute']);
        //authenticate request
       await jwtClient.authorize(function (err, tokens) {
         if (err) {
           console.log(err);
           return;
         } else {
           console.log("Successfully connected!"+ tokens.access_token); //displaying the token correctly
           return tokens.access_token; //returns the token
         }
        });
    }
  exports.consumepromise = async (req,res) =>{
  const tokennew =  await getGoogleApiToken();
  console.log("token"+tokennew);
  }
Run Code Online (Sandbox Code Playgroud)

错误:tokennew 未定义

不知道哪里出了问题。

return-value node.js async-await

1
推荐指数
1
解决办法
995
查看次数