fix port from config.yaml
This commit is contained in:
parent
372d82f711
commit
060fd75cb9
25
run.py
25
run.py
|
|
@ -15,6 +15,27 @@ try:
|
|||
except ImportError:
|
||||
colorama = None
|
||||
|
||||
def get_port():
|
||||
"""Get port from: 1) ENV variable, 2) config.yaml, 3) default 8000"""
|
||||
# Priority 1: Environment variable
|
||||
if os.getenv("PORT"):
|
||||
return os.getenv("PORT")
|
||||
|
||||
# Priority 2: config.yaml
|
||||
config_path = Path("config.yaml")
|
||||
if config_path.exists():
|
||||
try:
|
||||
import yaml
|
||||
with open(config_path, 'r', encoding='utf-8') as f:
|
||||
config = yaml.safe_load(f)
|
||||
if config and 'server' in config and 'port' in config['server']:
|
||||
return str(config['server']['port'])
|
||||
except Exception:
|
||||
pass # Fall through to default
|
||||
|
||||
# Priority 3: Default
|
||||
return "8000"
|
||||
|
||||
def main():
|
||||
print("🚀 Starting NoteDiscovery...\n")
|
||||
|
||||
|
|
@ -30,8 +51,8 @@ def main():
|
|||
Path("data").mkdir(parents=True, exist_ok=True)
|
||||
Path("plugins").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Get port from environment variable or use default
|
||||
port = os.getenv("PORT", "8000")
|
||||
# Get port from config or environment
|
||||
port = get_port()
|
||||
|
||||
print("✓ Dependencies installed")
|
||||
print("✓ Directories created")
|
||||
|
|
|
|||
Loading…
Reference in New Issue