Changed host parameters for webpage

This commit is contained in:
2026-01-28 12:41:58 -05:00
parent d960f6aa15
commit b5a4d84368
3 changed files with 22 additions and 7 deletions

View File

@@ -20,6 +20,8 @@ ASSIGNMENT_TIMEOUT=60
ASSIGNMENT_REMINDER=45
CHAIN_TIMER_THRESHOLD=5
# Server Configuration (optional)
# HOST=0.0.0.0
# PORT=8000
# Server Configuration
# HOST: Set to 0.0.0.0 to allow external connections, or 127.0.0.1 for localhost only
HOST=127.0.0.1
# PORT: Port to run the application on
PORT=8000

10
main.py
View File

@@ -100,9 +100,15 @@ async def start_bot():
async def main():
# Parse command-line arguments
import argparse
import os
# Read from environment variables first, then fall back to defaults
default_port = int(os.getenv("PORT", "8000"))
default_host = os.getenv("HOST", "127.0.0.1")
parser = argparse.ArgumentParser(description="Faction War Dispatch Bot")
parser.add_argument("--port", type=int, default=8000, help="Port to run the application on (default: 8000)")
parser.add_argument("--host", type=str, default="127.0.0.1", help="Host to bind to (default: 127.0.0.1)")
parser.add_argument("--port", type=int, default=default_port, help=f"Port to run the application on (default: {default_port})")
parser.add_argument("--host", type=str, default=default_host, help=f"Host to bind to (default: {default_host})")
args = parser.parse_args()
# Start Discord bot in background

View File

@@ -87,6 +87,10 @@ echo ""
echo "Setting up environment file..."
if [ ! -f ".env" ]; then
cp .env.example .env
# Update PORT in .env file
sed -i "s/^PORT=.*/PORT=$APP_PORT/" .env
echo ""
echo "IMPORTANT: You need to configure /opt/faction-war/app/.env with your secrets!"
echo ""
@@ -94,6 +98,8 @@ if [ ! -f ".env" ]; then
echo " - AUTH_PASSWORD: openssl rand -base64 32"
echo " - JWT_SECRET: openssl rand -hex 64"
echo ""
echo "Application port has been set to: $APP_PORT"
echo ""
echo "You can either:"
echo " 1. Edit the .env file now"
echo " 2. Skip and edit it later before starting the application"
@@ -112,8 +118,8 @@ chmod 600 .env
echo ""
echo "Setting up systemd service..."
# Update the service file with the configured port
sed "s|ExecStart=.*|ExecStart=/opt/faction-war/app/venv/bin/python main.py --port $APP_PORT|g" faction-war.service > /etc/systemd/system/faction-war.service
# Copy the service file
cp faction-war.service /etc/systemd/system/faction-war.service
systemctl daemon-reload
systemctl enable faction-war
systemctl start faction-war
@@ -159,6 +165,7 @@ echo ""
echo "Important next steps:"
echo "1. Configure /opt/faction-war/app/.env with your secrets (if not done already)"
echo " - Edit with: sudo -u factionwar nano /opt/faction-war/app/.env"
echo " - Change PORT or HOST in .env if needed"
echo " - Then restart: sudo systemctl restart faction-war"
echo "2. Access the application:"
echo " - Local: http://localhost:$APP_PORT"