Skip to content

Commit

Permalink
set_port
Browse files Browse the repository at this point in the history
  • Loading branch information
aamalev committed Oct 20, 2019
1 parent ebb3ebf commit 0ab6e15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion aioworkers_aiohttp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from aioworkers.core.plugin import Plugin

from .server import WebServer


try:
from .version import __version__
Expand Down Expand Up @@ -36,5 +38,5 @@ def parse_known_args(
namespace: argparse.Namespace,
) -> Tuple[argparse.Namespace, Iterable[str]]:
if namespace.port:
self._config['http.port'] = namespace.port
WebServer.set_port(namespace.port)
return namespace, args
8 changes: 8 additions & 0 deletions aioworkers_aiohttp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@


class WebServer(SocketServer):
port = None

@classmethod
def set_port(cls, port: int) -> None:
cls.port = port

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._runner = None
self._kwargs = {}

def set_config(self, config):
if self.port:
config = config.new_child(port=self.port)
super().set_config(config)
access_log_cls = self.config.get('access_log.cls')
if access_log_cls:
Expand Down

0 comments on commit 0ab6e15

Please sign in to comment.