Skip to content

Commit

Permalink
make host and port configurable for Jeff @ iBridge
Browse files Browse the repository at this point in the history
  • Loading branch information
samj committed Oct 1, 2024
1 parent 7b4acad commit cdaece0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions __main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import os
import sys
import signal
from pathlib import Path
Expand Down Expand Up @@ -41,8 +42,8 @@ def cleanup():
app = create_app()

# Define host and port
host = "localhost"
port = 8443
host = os.environ.get("PAIOS_HOST", "localhost")
port = int(os.environ.get("PAIOS_PORT", 8443))

# Log connection details
logger.info(f"You can access pAI-OS at https://{host}:{port}.")
Expand Down
5 changes: 3 additions & 2 deletions backend/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys
import signal
import asyncio
Expand Down Expand Up @@ -42,8 +43,8 @@ def cleanup():
app = create_app()

# Define host and port
host = "localhost"
port = 8443
host = os.environ.get("PAIOS_HOST", "localhost")
port = int(os.environ.get("PAIOS_PORT", 8443))

# Log connection details
logger.info(f"You can access pAI-OS at https://{host}:{port}.")
Expand Down

1 comment on commit cdaece0

@samj
Copy link
Contributor Author

@samj samj commented on cdaece0 Oct 1, 2024

Choose a reason for hiding this comment

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

Testing:

Defaults

% python -m paios
INFO:     Using existing certificate and key.
INFO:     Creating the app.
INFO:     Initializing database.
INFO:     Context impl SQLiteImpl.
INFO:     Will assume non-transactional DDL.
INFO:     You can access pAI-OS at https://localhost:8443.
INFO:     Bypass certificate warnings if using self-signed certificates.
INFO:     Running the app with uvicorn.
INFO:     Will watch for changes in these directories: ['/home/samj/paios/backend']
INFO:     Uvicorn running on https://localhost:8443 (Press CTRL+C to quit)
INFO:     Started reloader process [55206] using WatchFiles
INFO:     Initializing database.
INFO:     Context impl SQLiteImpl.
INFO:     Will assume non-transactional DDL.
INFO:     Started server process [55210]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
^CINFO:     Shutting down
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
INFO:     Finished server process [55210]
INFO:     Stopping reloader process [55206]
INFO:     Performing cleanup tasks.

Overrides

Do not try this at home - run as an unprivileged user.

% sudo PAIOS_HOST=192.168.1.100 PAIOS_PORT=443 python -m paios
Password:
INFO:     Using existing certificate and key.
INFO:     Creating the app.
INFO:     Initializing database.
INFO:     Context impl SQLiteImpl.
INFO:     Will assume non-transactional DDL.
INFO:     You can access pAI-OS at https://192.168.1.100:443.
INFO:     Bypass certificate warnings if using self-signed certificates.
INFO:     Running the app with uvicorn.
INFO:     Will watch for changes in these directories: ['/home/samj/paios/backend']
INFO:     Uvicorn running on https://192.168.1.100:443 (Press CTRL+C to quit)
INFO:     Started reloader process [55245] using WatchFiles
INFO:     Initializing database.
INFO:     Context impl SQLiteImpl.
INFO:     Will assume non-transactional DDL.
INFO:     Started server process [55247]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
^CINFO:     Shutting down
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
INFO:     Finished server process [55247]
INFO:     Stopping reloader process [55245]
INFO:     Performing cleanup tasks.

Please sign in to comment.