Skip to content

[BUG] server.py non legge le variabili d'ambiente GMP_* impostate da serve #92

@fporcari

Description

@fporcari

Problem Description

Il comando serve imposta variabili d'ambiente per configurare il server, ma server.py non le legge.

serve imposta:

os.environ["GMP_CONFIG_FILE"] = config_file
os.environ["GMP_INSTANCE_NAME"] = name
os.environ["GMP_DB_PATH"] = db_path
os.environ["GMP_PORT"] = str(effective_port)
os.environ["GMP_HOST"] = effective_host

server.py fa:

_proxy = MailProxy()  # ← nessuna configurazione!
app = _proxy.api

ProxyConfig default:

db_path: str = "/data/mail_service.db"  # ← path che non esiste

Reproduction Steps

mail-proxy serve default-mailer

Error

sqlite3.OperationalError: unable to open database file

Il server cerca /data/mail_service.db invece di ~/.mail-proxy/default-mailer/mail_service.db

Proposed Fix

Opzione A - server.py legge le variabili:

import os
from .proxy import MailProxy
from .proxy_config import ProxyConfig

config = ProxyConfig(
    db_path=os.environ.get("GMP_DB_PATH", "/data/mail_service.db"),
    instance_name=os.environ.get("GMP_INSTANCE_NAME", "mail-proxy"),
    port=int(os.environ.get("GMP_PORT", "8000")),
    api_token=os.environ.get("GMP_API_TOKEN"),
)
_proxy = MailProxy(config=config)
app = _proxy.api

Opzione B - ProxyConfig.__init__ legge le variabili automaticamente

Environment

  • Version: 0.7.x
  • OS: macOS / Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions