503:使用 Github Probot 的 AWS Lambda 服务不可用

问题描述

我正在尝试使用 probot 应用程序从 Github 接收网络钩子,但每次尝试此操作时,我都会收到 {"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
    
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)