Add restart function / options change (#1242)

This commit is contained in:
Pascal Vizeli 2019-08-18 11:46:23 +02:00 committed by GitHub
parent ee2c257057
commit 1f448744f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

2
API.md
View File

@ -771,6 +771,8 @@ return:
}
```
- POST `/dns/restart`
- GET `/dns/logs`
- GET `/dns/stats`

View File

@ -278,6 +278,7 @@ class RestAPI(CoreSysAttributes):
web.get("/dns/logs", api_dns.logs),
web.post("/dns/update", api_dns.update),
web.post("/dns/options", api_dns.options),
web.post("/dns/restart", api_dns.restart),
]
)

View File

@ -54,6 +54,7 @@ class APICoreDNS(CoreSysAttributes):
if ATTR_SERVERS in body:
self.sys_dns.servers = body[ATTR_SERVERS]
self.sys_create_task(self.sys_dns.restart())
self.sys_dns.save_data()
@ -87,3 +88,8 @@ class APICoreDNS(CoreSysAttributes):
def logs(self, request: web.Request) -> Awaitable[bytes]:
"""Return DNS Docker logs."""
return self.sys_dns.logs()
@api_process
def restart(self, request: web.Request) -> Awaitable[None]:
"""Restart CoreDNS plugin."""
return asyncio.shield(self.sys_dns.restart())