-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Description & Motivation
I am trying to deploy Pose App on a local network as I don't have access to the machine in-person.
In localhost-mode, the App spawns multiple Lightning Works that occupy random ports. This makes it hard to open the needed ports in the firewall. Opening up all ports is obviously not wanted. So simply setting the app URL to 0.0.0.0 would also not help in this case.
Example of running lsof -i -P -n | grep LISTEN
python 83652 abdelhaym 9u IPv4 458580 0t0 TCP 127.0.0.1:58537 (LISTEN)
python 83652 abdelhaym 10u IPv6 458581 0t0 TCP [::1]:58537 (LISTEN)
python 83653 abdelhaym 9u IPv4 488642 0t0 TCP 127.0.0.1:35337 (LISTEN)
python 83653 abdelhaym 10u IPv6 488643 0t0 TCP [::1]:35337 (LISTEN)
python 83654 abdelhaym 9u IPv4 465625 0t0 TCP 127.0.0.1:33571 (LISTEN)
python 83654 abdelhaym 10u IPv6 465626 0t0 TCP [::1]:33571 (LISTEN)
python 83655 abdelhaym 9u IPv4 485462 0t0 TCP 127.0.0.1:37229 (LISTEN)
python 83655 abdelhaym 10u IPv6 485463 0t0 TCP [::1]:37229 (LISTEN)
pt_main_t 83657 abdelhaym 31u IPv4 480899 0t0 TCP 127.0.0.1:7501 (LISTEN)
label-stu 83775 abdelhaym 5u IPv4 467897 0t0 TCP 127.0.0.1:56903 (LISTEN)
python3.1 84173 abdelhaym 7u IPv4 488698 0t0 TCP 127.0.0.1:49879 (LISTEN)
When I set LIGHTNING_CLOUDSPACE_HOST=0 and LIGHTNING_CLOUDSPACE_EXPOSED_PORT_COUNT=15 the app runs through 0.0.0.0 and the ports follow span the range from 7501 till 7515.
python 85048 abdelhaym 9u IPv4 466716 0t0 TCP *:7502 (LISTEN)
python 85049 abdelhaym 9u IPv4 465756 0t0 TCP *:7503 (LISTEN)
python 85050 abdelhaym 9u IPv4 481099 0t0 TCP *:7504 (LISTEN)
python 85051 abdelhaym 9u IPv4 475878 0t0 TCP *:7505 (LISTEN)
pt_main_t 85053 abdelhaym 31u IPv4 484872 0t0 TCP *:7501 (LISTEN)
label-stu 85120 abdelhaym 5u IPv4 475897 0t0 TCP *:7508 (LISTEN)
python3.1 85422 abdelhaym 7u IPv4 486706 0t0 TCP *:7506 (LISTEN)
This seems to work. But the app doesn't load. One of the instances (the project_ui instance) creates a weird URL that looks like so: https://7503-0/root.project_ui
I tried to trace this down and got to some like in the multiprocess code. This one:
| work._future_url = f"https://{work.port}-{constants.LIGHTNING_CLOUDSPACE_HOST}" |
And this one:
| f"https://{port}-{constants.LIGHTNING_CLOUDSPACE_HOST}" |
This seems to be the url that is generated when 'LIGHTNING_CLOUDSPACE_HOST' is set. I tried to set it to "any", "", or "0.0.0.0" with the same issue.
I got it working by editing those to lines to this: f"http://<machine_hostname>:{port}"
Maybe I am missing something, but I couldn't find a better workaround.
Pitch
Setting 'LIGHTNING_CLOUDSPACE_HOST' seems to trigger the app and works to use consecutive ports to run.
Is it possible to allow the same mechanism when 'LIGHTNING_CLOUDSPACE_HOST' is unset?
This way, we would only have to set LIGHTNING_APP_STATE_URL to 0.0.0.0 without messing with the cloud deployment loagic.
Alternatives
No response
Additional context
Version 2.2.5
cc @Borda