Changed host parameters for webpage
This commit is contained in:
@@ -20,6 +20,8 @@ ASSIGNMENT_TIMEOUT=60
|
|||||||
ASSIGNMENT_REMINDER=45
|
ASSIGNMENT_REMINDER=45
|
||||||
CHAIN_TIMER_THRESHOLD=5
|
CHAIN_TIMER_THRESHOLD=5
|
||||||
|
|
||||||
# Server Configuration (optional)
|
# Server Configuration
|
||||||
# HOST=0.0.0.0
|
# HOST: Set to 0.0.0.0 to allow external connections, or 127.0.0.1 for localhost only
|
||||||
# PORT=8000
|
HOST=127.0.0.1
|
||||||
|
# PORT: Port to run the application on
|
||||||
|
PORT=8000
|
||||||
|
|||||||
10
main.py
10
main.py
@@ -100,9 +100,15 @@ async def start_bot():
|
|||||||
async def main():
|
async def main():
|
||||||
# Parse command-line arguments
|
# Parse command-line arguments
|
||||||
import argparse
|
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 = 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("--port", type=int, default=default_port, help=f"Port to run the application on (default: {default_port})")
|
||||||
parser.add_argument("--host", type=str, default="127.0.0.1", help="Host to bind to (default: 127.0.0.1)")
|
parser.add_argument("--host", type=str, default=default_host, help=f"Host to bind to (default: {default_host})")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Start Discord bot in background
|
# Start Discord bot in background
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ echo ""
|
|||||||
echo "Setting up environment file..."
|
echo "Setting up environment file..."
|
||||||
if [ ! -f ".env" ]; then
|
if [ ! -f ".env" ]; then
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
|
|
||||||
|
# Update PORT in .env file
|
||||||
|
sed -i "s/^PORT=.*/PORT=$APP_PORT/" .env
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "IMPORTANT: You need to configure /opt/faction-war/app/.env with your secrets!"
|
echo "IMPORTANT: You need to configure /opt/faction-war/app/.env with your secrets!"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -94,6 +98,8 @@ if [ ! -f ".env" ]; then
|
|||||||
echo " - AUTH_PASSWORD: openssl rand -base64 32"
|
echo " - AUTH_PASSWORD: openssl rand -base64 32"
|
||||||
echo " - JWT_SECRET: openssl rand -hex 64"
|
echo " - JWT_SECRET: openssl rand -hex 64"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "Application port has been set to: $APP_PORT"
|
||||||
|
echo ""
|
||||||
echo "You can either:"
|
echo "You can either:"
|
||||||
echo " 1. Edit the .env file now"
|
echo " 1. Edit the .env file now"
|
||||||
echo " 2. Skip and edit it later before starting the application"
|
echo " 2. Skip and edit it later before starting the application"
|
||||||
@@ -112,8 +118,8 @@ chmod 600 .env
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Setting up systemd service..."
|
echo "Setting up systemd service..."
|
||||||
# Update the service file with the configured port
|
# Copy the service file
|
||||||
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
|
cp faction-war.service /etc/systemd/system/faction-war.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable faction-war
|
systemctl enable faction-war
|
||||||
systemctl start faction-war
|
systemctl start faction-war
|
||||||
@@ -159,6 +165,7 @@ echo ""
|
|||||||
echo "Important next steps:"
|
echo "Important next steps:"
|
||||||
echo "1. Configure /opt/faction-war/app/.env with your secrets (if not done already)"
|
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 " - 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 " - Then restart: sudo systemctl restart faction-war"
|
||||||
echo "2. Access the application:"
|
echo "2. Access the application:"
|
||||||
echo " - Local: http://localhost:$APP_PORT"
|
echo " - Local: http://localhost:$APP_PORT"
|
||||||
|
|||||||
Reference in New Issue
Block a user