1

我正在尝试使用 probot 应用程序从 Github 接收 webhook,但每次尝试此操作时,都会出现{"message":"Service Unavailable"}错误。

Github 将此有效负载发送到 AWS Lambda 函数,通过谷歌搜索(我认为)这是一个没有足够节点来处理请求数量的问题。

要么我的代码有问题,要么配置有错误。

我正在使用无服务器框架上传到 AWS lambda。

这是代码失败的部分(日志中没有错误消息,机器人刚刚退出):

const yamlFile = async (context) => {
  try {
    console.log("trying to get yaml")
    var yamlfile = await context.octokit.repos.getContent({
      owner: context.payload.repository.owner.login,
      repo: context.payload.repository.name,
      path: ".bit/config.yml",
    });
    console.log(yamlfile)
  } catch (e) {
    console.log("Error with getting content of yaml");
    console.log(e)
    return null
  }
  console.log("got yaml, but no content yet");
  yamlfile = Buffer.from(yamlfile.data.content, 'base64').toString()
  console.log(yamlfile)
  try {
    let fileContents = yamlfile
    configyml = yaml.load(fileContents);
  } catch (e) {
    const issueBody = context.issue({
      title: "[ERROR] Please read",
      body: `There was an issue parsing the config file of this course. Please contact your counselor and send them the below error.\n${e}`,
    });

    context.octokit.issues.create(issueBody)
    console.log("ERROR: " + e);
    return null
  }
  console.log("returining configyml")
  return configyml;
}

该函数yamlFile()在我们的主函数中被调用:

let currentStep = ""
let configData = await data.yamlFile(context);
console.log(configData)
if (configData == null) {
  console.log("null config data");
  return
}

AWS 配置

  • 超时:60 秒

serverless.yml对于无服务器框架:

service: <SERVICE NAME>

# app and org for use with dashboard.serverless.com
app: <APP NAME>
org: <ORG NAME>

frameworkVersion: "2"
useDotenv: true

provider:
  name: aws
  runtime: nodejs12.x
  lambdaHashingVersion: 20201221
  environment:
    APP_ID: ${param:APP_ID}
    PRIVATE_KEY: ${param:PRIVATE_KEY}
    WEBHOOK_SECRET: ${param:WEBHOOK_SECRET}
    NODE_ENV: production
    LOG_LEVEL: debug
  memorySize: 2048

functions:
  webhooks:
    handler: handler.webhooks
    memorySize: 2048
    events:
      - httpApi:
          path: /api/github/webhooks
          method: post
    
    
4

0 回答 0