Skip to content

Commit

Permalink
Add CWD to sys.path in server commands
Browse files Browse the repository at this point in the history
This makes it possible to run baseplate-serve etc. on a package in the
local directory without having to install it onto the path. Not
necessary but a nice improvement for quick-start type situations.
  • Loading branch information
spladug committed Aug 9, 2019
1 parent 8ac34f1 commit 78d27b8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions baseplate/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import importlib
import inspect
import logging.config
import os
import signal
import socket
import sys
Expand Down Expand Up @@ -210,6 +211,9 @@ def _handle_shutdown_signal(_signo: int, _frame: FrameType) -> None:

def load_app_and_run_server() -> None:
"""Parse arguments, read configuration, and start the server."""

sys.path.append(os.getcwd())

shutdown_event = register_signal_handlers()

args = parse_args(sys.argv[1:])
Expand Down Expand Up @@ -241,6 +245,9 @@ def load_app_and_run_server() -> None:

def load_and_run_script() -> None:
"""Launch a script with an entrypoint similar to a server."""

sys.path.append(os.getcwd())

parser = argparse.ArgumentParser(
description="Run a function with app configuration loaded.",
formatter_class=argparse.RawDescriptionHelpFormatter,
Expand Down Expand Up @@ -304,6 +311,9 @@ def _fn_accepts_additional_args(script_fn: Callable[..., Any], fn_args: Sequence

def load_and_run_tshell() -> None:
"""Launch a shell for a thrift service."""

sys.path.append(os.getcwd())

parser = argparse.ArgumentParser(
description="Open a shell for a Thrift service with app configuration loaded.",
formatter_class=argparse.RawDescriptionHelpFormatter,
Expand Down

0 comments on commit 78d27b8

Please sign in to comment.