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

Allow users to configure the webserver port #1858

Merged
merged 4 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ The types of changes are:
* `Fixed` for any bug fixes.
* `Security` in case of vulnerabilities.


## [Unreleased](https://github.com/ethyca/fides/compare/2.1.0...main)

### Added
Expand All @@ -25,6 +24,7 @@ The types of changes are:
* Access and erasure support for Fullstory API [#1821](https://github.com/ethyca/fides/pull/1821)

### Changed

* The organization info form step is now skipped if the server already has organization info. [#1840](https://github.com/ethyca/fides/pull/1840)

### Fixed
Expand Down Expand Up @@ -53,6 +53,7 @@ The types of changes are:
* Privacy-Center-Cypress workflow for CI checks of the Privacy Center. [#1722](https://github.com/ethyca/fides/pull/1722)
* Privacy Center `fides-consent.js` script for accessing consent on external pages. [Details](/clients/privacy-center/packages/fides-consent/README.md)
* Erasure support for Twilio Conversations API [#1673](https://github.com/ethyca/fides/pull/1673)
* Webserver port can now be configured via the CLI command [#1858](https://github.com/ethyca/fides/pull/1858)

### Changed

Expand Down
10 changes: 7 additions & 3 deletions src/fides/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,12 @@ def read_other_paths(request: Request) -> Response:
return get_admin_index_as_response()


def start_webserver() -> None:
"Run the webserver."
def start_webserver(port: int = 8080) -> None:
"""Run the webserver."""
check_required_webserver_config_values()
server = Server(Config(app, host="0.0.0.0", port=8080, log_level=WARNING))
server = Server(Config(app, host="0.0.0.0", port=port, log_level=WARNING))

log.info(
f"Starting webserver - Host: {server.config.host}, Port: {server.config.port}, Log Level: {server.config.log_level}"
)
server.run()
7 changes: 4 additions & 3 deletions src/fides/cli/commands/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ def status(ctx: click.Context) -> None:

@click.command()
@click.pass_context
def webserver(ctx: click.Context) -> None:
@click.option("--port", "-p", type=int, default=8080)
def webserver(ctx: click.Context, port: int=8080) -> None:
"""
Starts the fides API server using Uvicorn on port 8080.
Starts the fides API server using Uvicorn.
"""
# This has to be here to avoid a circular dependency
from fides.api.main import start_webserver

start_webserver()
start_webserver(port=port)


@click.command()
Expand Down
1 change: 1 addition & 0 deletions src/fides/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def create_config_file(ctx: click.Context, fides_directory_location: str = ".")
}

# create the .fides dir if it doesn't exist
print_divider()
if not os.path.exists(fides_dir_path):
os.mkdir(fides_dir_path)
click.echo(f"Created a '{fides_dir_path}' directory.")
Expand Down