微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Uvicorn 自动关闭

如何解决Uvicorn 自动关闭

尝试在共享托管服务器 (Linux Debian) 上启动 uvicorn:

const _app = new PIXI.Application({width:1000,height:200})
var g = new PIXI.Graphics()

const series = []

for(let i=0; i<100; i++){
  series.push([i,~~(Math.random()*100)])
}

let zoomFactor = 0.01

requestAnimationFrame(animate)

async function animate() {
  zoomFactor=(Math.sin(+new Date()/1000)*10+15)
  redraw(zoomFactor)
  //await new Promise(rs => setTimeout(rs,100))
  requestAnimationFrame(animate)
}

const init = (factor = 1) => {
  g.clear()
  for(let i = 0 ; i < 10; i++){
    g.position.set(0,0)
    g.moveto(0,series[i]+(i*10))
    series.forEach((point,index) => {
      let x = point[0]
      let y = point[1]+ (i*10)
      const pre = series[index-1] || 0

            g.drawCircle(x*factor,y,4)
      g.linestyle(1,index % 2 ? 0xffffff : 0xff0000,0.5)
      g.lineto(x * (factor),y)
    })
  }
}

init()

function redraw(zoomFactor) {
  init(zoomFactor)
}


document.getElementById('chart').appendChild(_app.view)
_app.stage.addChild(g)

uvicorn 启动,可以处理几个 HTTP GET,但在 30 秒左右后关闭。 这是错误消息:

uvicorn etebase_server.asgi:application --port 8000 --host 0.0.0.0 --lifespan on

INFO: Started server process [125907] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) INFO: Shutting down INFO: Waiting for application shutdown. ERROR: Exception in 'lifespan' protocol Traceback (most recent call last): File "/XXX/etebase/.venv/lib/python3.7/site-packages/uvicorn/lifespan/on.py",line 55,in main await app(scope,self.receive,self.send) File "/XXX/etebase/.venv/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py",line 45,in call return await self.app(scope,receive,send) File "/XXX/etebase/.venv/lib/python3.7/site-packages/fastapi/applications.py",line 199,in call await super().call(scope,send) File "/XXX/etebase/.venv/lib/python3.7/site-packages/starlette/applications.py",line 111,in call await self.middleware_stack(scope,send) File "/XXX/etebase/.venv/lib/python3.7/site-packages/starlette/middleware/errors.py",line 146,in call await self.app(scope,send) File "/XXX/etebase/.venv/lib/python3.7/site-packages/starlette/middleware/trustedhost.py",line 34,send) File "/XXX/etebase/.venv/lib/python3.7/site-packages/starlette/middleware/cors.py",line 70,send) File "/XXX/etebase/.venv/lib/python3.7/site-packages/starlette/exceptions.py",line 58,send) File "/XXX/etebase/.venv/lib/python3.7/site-packages/starlette/routing.py",line 555,in call await self.lifespan(scope,line 526,in lifespan async for item in self.lifespan_context(app): File "/XXX/etebase/.venv/lib/python3.7/site-packages/starlette/routing.py",line 469,in default_lifespan await self.shutdown() File "/XXX/etebase/.venv/lib/python3.7/site-packages/starlette/routing.py",line 512,in shutdown await handler() File "./etebase_fastapi/main.py",line 71,in on_shutdown await redisw.close() File "./etebase_fastapi/redis.py",line 18,in close if self.redis is not None: AttributeError: 'RedisWrapper' object has no attribute 'redis' INFO: Application shutdown complete. INFO: Finished server process [125907] 有什么想法吗???

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。