aio-libs / aiohttp-devtools

dev tools for aiohttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

disable the aux server when neither reload nor static server are required

sky-code opened this issue · comments

Will be good to provide an option to disable static serving for people who use aiohttp only as a API server and not need a static file serving from devtools livereload server.
In one of my project I use aiohttp as rest api server and when I use livereload server from aiohttp devtools and when server is restarting during to changes, bootstrap of my app occurs twice (one for server and one for static files server).
I will try to implement this, and make a pr.

adev runserver --help
Usage: adev runserver [OPTIONS] [APP_PATH]
...
Options:
  -s, --static DIRECTORY          Path of static files to serve, if excluded
                                  static files aren't served. env variable:
                                  AIO_STATIC_STATIC
...

What's wrong with just not supplying a --static option?

I not use --static option, this is my options runserver --no-livereload -p 8888 project
But when changes have occurred my app loading twice

image

look at bootstrap_app.complete log entry, one for 8888 port and one for 8889.

For each code changes app reloading two times.

Is this possible to avoid aux app usage or aux app required as master server?

the 8001 server always runs even if it's not doing anything, that could be fixed but I don't think it's the real problem here.

I don't know why your code is reloading twice. This is the problem and should be fixed.

If you run a simple server like

from aiohttp import web
import asyncio

async def handle(request):
    return web.Response(text=f'loop: {request.app.loop}')

app = web.Application()
app.router.add_get('/', handle)

Does that reload twice on a change?

Is the number of files being watched very large?

Could you give OS, and version details as the issue template suggests?

Sorry my bad. Code loading twice but reloading only dev server.
Ideally option to disable aux will be good, but not so critical.
I gues issue can be closed.

Thanks, it would be better to be fixed, I'll leave this open.