如何使用python 3.5+ sanic框架configurationapp.yaml文件的appengine

我是GCP新手,我们select了sanic框架来让事情更顺畅。 Sanic支持python 3.5+,所以我们在appengine上使用灵活的环境。

目前我正在尝试将“Sanic” Hello world(入门)应用程序部署到appengine。 并坚持configuration。 问题在

# This looks like a Python app. If so, please enter the command to run the app in production (enter nothing if it's not a python app): : 

我曾经看过其他的Google云端平台(Python文档示例),这些例子在GitHub上都可以使用gunicorn,但sanic已经内置了http服务器。

有人可以build议在appengine的sanic app.yaml模型。 我目前的设置如下

1. app.yaml

  runtime: python env: flex threadsafe: true runtime_config: python_version: 3 handlers: - url: .* # This regex directs all routes to main.app script: main.app 

2. main.py

 #import logging from sanic import Sanic from sanic.response import json app = Sanic() @app.route("/") async def test(request): return json({"hello": "world"}) if __name__ == "__main__": app.run(host="0.0.0.0", port=8000) 

3. requirements.txt

 httptools sanic ujson uvloop 

UPDATE。

添加entrypoint: python main.pyapp.yaml修复了我的部署问题,但appengine throughs错误。

错误:服务器错误
服务器遇到临时错误,无法完成您的请求。 请在30秒后重试。

提前致谢。 如果你不能解决我的问题不投票。

确切的说,这里是appengine app.yaml入口点模型:

entrypoint: gunicorn <main:app> --bind 0.0.0.0:8080 --worker-class sanic.worker.GunicornWorker

您需要确保安装gunicorn pip软件包。 目前Appengine支持gunicorn版本19.7.1。

我不确定以下是否有帮助。

我有同样的问题。 解决:

  1. 添加entrypoint: gunicorn -b :$PORT main:app到我的app.yaml文件。
  2. 在我的requirements.txt文件中join"gunicorn==19.7.1"