Skip to content

feat(vtkw_server): dynamic port and data_folder_path #22

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

Merged
merged 1 commit into from
Jun 28, 2024
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
2 changes: 1 addition & 1 deletion src/opengeodeweb_viewer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def default_config():
os.environ["HOST"] = "0.0.0.0"
os.environ["PORT"] = "1234"
os.environ["DEFAULT_PORT"] = "1234"


def prod_config():
Expand Down
10 changes: 7 additions & 3 deletions src/opengeodeweb_viewer/vtkw_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class _Server(vtk_wslink.ServerProtocol):
# Defaults
authKey = "wslink-secret"
view = None
debug = False

@staticmethod
def add_arguments(parser):
parser.add_argument(
"--virtual-env", default=None, help="Path to virtual environment to use"
"--data_folder_path", default=os.environ.get("DATA_FOLDER_PATH"), help="Path to the folder where data is stored"
)

@staticmethod
Expand Down Expand Up @@ -70,6 +71,7 @@ def initialize(self):
widget.SetOrientationMarker(axes)
widget.EnabledOn()
widget.InteractiveOff()
renderWindow.SetOffScreenRendering(not _Server.debug)
self.setSharedObject("marker", widget)


Expand All @@ -94,10 +96,12 @@ def run_server():

_Server.add_arguments(parser)
args = parser.parse_args()
args.port = os.environ.get("PORT")
if not "port" in args or args.port == 8080:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you discard port 8080?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Port is already in the default argments and if I don't specify that is run on 8080, and I don't want any breaking change

args.port = os.environ.get("DEFAULT_PORT")
if "data_folder_path" in args:
os.environ["DATA_FOLDER_PATH"] = args.data_folder_path
args.host = os.environ.get("HOST")
print(f"{args=}", flush=True)

_Server.configure(args)
server.start_webserver(options=args, protocol=_Server)

Expand Down