Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'markdoc serve' ignores server settings in markdoc.yaml #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/markdoc/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,16 @@ def serve(config, args):
log = logging.getLogger('markdoc.serve')
app = MarkdocWSGIApplication(config)

config['server.port'] = args.port
config['server.num-threads'] = args.num_threads
if args.port:
config['server.port'] = args.port
if args.num_threads:
config['server.num-threads'] = args.num_threads
if args.server_name:
config['server.name'] = args.server_name
config['server.request-queue-size'] = args.queue_size
config['server.timeout'] = args.timeout
if args.queue_size:
config['server.request-queue-size'] = args.queue_size
if args.timeout:
config['server.timeout'] = args.timeout
if args.interface:
if not IPV4_RE.match(args.interface):
serve.parser.error('invalid interface specifier: %r' % args.interface)
Expand All @@ -349,16 +353,19 @@ def serve(config, args):
log.info('Shutting down gracefully')
server.stop()

serve.parser.add_argument('-p', '--port', type=int, default=8008,
# Don't set defaults here because they will override the user's
# settings in markdoc.yaml. Set them in server.py instead.

serve.parser.add_argument('-p', '--port', type=int,
help="Listen on specified port (default is 8008)")
serve.parser.add_argument('-i', '--interface', default=None,
serve.parser.add_argument('-i', '--interface',
help="Bind to specified interface (defaults to loopback only)")
serve.parser.add_argument('-t', '--num-threads', type=int, default=10, metavar='N',
serve.parser.add_argument('-t', '--num-threads', type=int, metavar='N',
help="Use N threads to handle requests (default is 10)")
serve.parser.add_argument('-n', '--server-name', default=None, metavar='NAME',
serve.parser.add_argument('-n', '--server-name', metavar='NAME',
help="Use an explicit server name (default to an autodetected value)")
serve.parser.add_argument('-q', '--queue-size', type=int, default=5, metavar='SIZE',
serve.parser.add_argument('-q', '--queue-size', type=int, metavar='SIZE',
help="Set request queue size (default is 5)")
serve.parser.add_argument('--timeout', type=int, default=10,
serve.parser.add_argument('--timeout', type=int,
help="Set the socket timeout for connections (default is 10)")