midwayjs / midway

🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈
https://www.midwayjs.org/
MIT License
7.4k stars 576 forks source link

请教个关于midway egg项目serverless fc迁移适配的问题? #2884

Closed mexhfl closed 1 year ago

mexhfl commented 1 year ago

现有的midway egg项目,想迁移到阿里云serverless fc,按照官方文档egg应用迁移配置之后,发布到阿里云fc,请求接口报错。 为了避免是我业务代码的问题,我重新创建了一个新的midway egg项目,什么都没改,直接按照官方文档配置了serverless fc适配,发布到阿里云之后,报一样的错。 我把请求的报错信息贴出来,大家看看该如何解决。

{ "errorMessage": "Cannot read property 'listen' of undefined", "errorType": "TypeError", "stackTrace": [ "TypeError: Cannot read property 'listen' of undefined", " at (/code/node_modules/@midwayjs/egg-layer/index.js:74:16)", " at Promise (null:null:null)", " at beforeRuntimeStart (/code/node_modules/@midwayjs/egg-layer/index.js:73:13)", " at handlerInvokerWrapper (/code/node_modules/@midwayjs/runtime-engine/dist/runtime.js:169:31)", " at runtimeStart (/code/node_modules/@midwayjs/runtime-engine/dist/runtime.js:32:20)", " at ready (/code/node_modules/@midwayjs/runtime-engine/dist/engine.js:54:40)", " at start (/code/node_modules/@midwayjs/runtime-engine/dist/bootstrap.js:22:9)", " at start (/code/node_modules/@midwayjs/serverless-fc-starter/dist/index.js:37:5)", " at (/code/index.js:19:15)" ] }

czy88840616 commented 1 year ago

参考 https://help.aliyun.com/document_detail/425055.html?spm=a2c4g.132044.0.0.26821266p7TQyX

mexhfl commented 1 year ago

参考 https://help.aliyun.com/document_detail/425055.html?spm=a2c4g.132044.0.0.26821266p7TQyX

按这样配置以后,已经配置了命令和参数,配置了server.js,运行npm run deploy部署之后,请求依然提示错误:"The function cannot be started. Failed to start function instance. Error: the file /code/bootstrap is not exist"

czy88840616 commented 1 year ago

The function cannot be started. Failed to start function instance. Error: the file /code/bootstrap is not exist"

意思就是找不到 bootstrap 文件(不是midway 的 bootstrap.js)

1、要按照 fc 文档上的示例写 bootstrap 文件 2、应该是直接用 s 部署,不要用 npm run deploy

mexhfl commented 1 year ago

The function cannot be started. Failed to start function instance. Error: the file /code/bootstrap is not exist"

意思就是找不到 bootstrap 文件(不是midway 的 bootstrap.js)

1、要按照 fc 文档上的示例写 bootstrap 文件 2、应该是直接用 s 部署,不要用 npm run deploy

有几个问题想请教一下: 1、是否可以发我一下bootstrap的示例文档?我试了好多都没能运行起来。 2、您说的用s部署是通过npx serverless deploy部署吗? 3、是否有必要在f.yml中配置启动命令和参数?还是用默认的bootstrap就可以?

czy88840616 commented 1 year ago

我翻了下文档似乎没找到很详细的(自动换成 serverlessdevs 之后)

可以看看这个示例。 https://www.devsapp.cn/details.html?name=start-midway-koahttps://www.devsapp.cn/details.html?name=start-midway-koa@2799546190

2、用s部署是通过npx serverless deploy部署吗? 是 3、是否有必要在f.yml中配置启动命令和参数?我理解不需要 f.yml 了

mexhfl commented 1 year ago

用serverlessdevs可以了,感谢!

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.