Issue #73: add port number option.

This commit is contained in:
Sergey Vartanov 2021-08-29 12:27:06 +03:00
parent 78e1415363
commit 3b5aed9356
4 changed files with 20 additions and 7 deletions

View file

@ -155,7 +155,7 @@ will download OSM data to `cache/2.284,48.860,2.290,48.865.osm` and write output
| <span style="white-space: nowrap;">`--cache`</span> `<path>` | path for temporary OSM files, default value: `cache` | | <span style="white-space: nowrap;">`--cache`</span> `<path>` | path for temporary OSM files, default value: `cache` |
| <span style="white-space: nowrap;">`-z`</span>, <span style="white-space: nowrap;">`--zoom`</span> `<integer>` | OSM zoom level, default value: 18 | | <span style="white-space: nowrap;">`-z`</span>, <span style="white-space: nowrap;">`--zoom`</span> `<integer>` | OSM zoom level, default value: 18 |
+ see [map configuration options](#map-options) plus [map configuration options](#map-options)
Tile generation Tile generation
--------------- ---------------
@ -170,7 +170,7 @@ Command `tile` is used to generate PNG tiles for [slippy maps](https://wiki.open
| <span style="white-space: nowrap;">`-b`</span>, <span style="white-space: nowrap;">`--boundary-box`</span> `<lon1>,<lat1>,<lon2>,<lat2>` | construct the minimum amount of tiles that cover requested boundary box | | <span style="white-space: nowrap;">`-b`</span>, <span style="white-space: nowrap;">`--boundary-box`</span> `<lon1>,<lat1>,<lon2>,<lat2>` | construct the minimum amount of tiles that cover requested boundary box |
| <span style="white-space: nowrap;">`-z`</span>, <span style="white-space: nowrap;">`--zoom`</span> `<integer>` | OSM zoom levels; can be list of numbers or ranges, e.g. `16-18`, `16,17,18`, or `16,18-20`, default value: `18` | | <span style="white-space: nowrap;">`-z`</span>, <span style="white-space: nowrap;">`--zoom`</span> `<integer>` | OSM zoom levels; can be list of numbers or ranges, e.g. `16-18`, `16,17,18`, or `16,18-20`, default value: `18` |
+ see [map configuration options](#map-options) plus [map configuration options](#map-options)
### Generate one tile ### ### Generate one tile ###
@ -229,6 +229,11 @@ roentgen server
Stop server interrupting process with <kbd>Ctrl</kbd> + <kbd>C</kbd>. Stop server interrupting process with <kbd>Ctrl</kbd> + <kbd>C</kbd>.
| Option | Description |
|---|---|
| <span style="white-space: nowrap;">`--cache`</span> `<path>` | path for temporary OSM files, default value: `cache` |
| <span style="white-space: nowrap;">`--port`</span> `<integer>` | port number, default value: 8080 |
### Example ### ### Example ###
Create a minimal amount of tiles that cover specified boundary box for zoom levels 16, 17, 18, and 19: Create a minimal amount of tiles that cover specified boundary box for zoom levels 16, 17, 18, and 19:

View file

@ -190,7 +190,7 @@ will download OSM data to \m {cache/2.284,48.860,2.290,48.865.osm} and write out
\options {render} \options {render}
+ see \ref {#map-options} {map configuration options} plus \ref {#map-options} {map configuration options}
\2 {Tile generation} {tile-generation} \2 {Tile generation} {tile-generation}
@ -198,7 +198,7 @@ Command \m {tile} is used to generate PNG tiles for \ref {https://wiki.openstree
\options {tile} \options {tile}
+ see \ref {#map-options} {map configuration options} plus \ref {#map-options} {map configuration options}
\3 {Generate one tile} {generate-one-tile} \3 {Generate one tile} {generate-one-tile}
@ -244,6 +244,8 @@ Command \m {server} is used to run tile server for slippy maps.
Stop server interrupting process with \kbd {Ctrl} + \kbd {C}. Stop server interrupting process with \kbd {Ctrl} + \kbd {C}.
\options {server}
\3 {Example} {example} \3 {Example} {example}
Create a minimal amount of tiles that cover specified boundary box for zoom levels 16, 17, 18, and 19\: Create a minimal amount of tiles that cover specified boundary box for zoom levels 16, 17, 18, and 19\:

View file

@ -70,12 +70,11 @@ def ui(options: argparse.Namespace) -> None:
"""Command-line interface for tile server.""" """Command-line interface for tile server."""
server: Optional[HTTPServer] = None server: Optional[HTTPServer] = None
try: try:
port: int = 8080
handler = _Handler handler = _Handler
handler.cache = Path(options.cache) handler.cache = Path(options.cache)
handler.options = options handler.options = options
server: HTTPServer = HTTPServer(("", port), handler) server: HTTPServer = HTTPServer(("", options.port), handler)
logging.info(f"Server started on port {port}.") logging.info(f"Server started on port {options.port}.")
server.serve_forever() server.serve_forever()
finally: finally:
if server: if server:

View file

@ -133,6 +133,13 @@ def add_server_arguments(parser: argparse.ArgumentParser) -> None:
default="cache", default="cache",
metavar="<path>", metavar="<path>",
) )
parser.add_argument(
"--port",
help="port number",
default=8080,
type=int,
metavar="<integer>",
)
def add_element_arguments(parser: argparse.ArgumentParser) -> None: def add_element_arguments(parser: argparse.ArgumentParser) -> None: