# systemd unit — PlytixMage FastAPI (uvicorn multi-worker, enqueue-only) # # Goal: keep HTTP responsive. Long Magento/channel/taxonomy/readiness jobs # must stay in their dedicated worker units (do NOT enable embedded workers here). # # Install: # sudo cp scripts/systemd/plytixmage-api.service /etc/systemd/system/ # sudo systemctl daemon-reload # sudo systemctl enable --now plytixmage-api.service # journalctl -u plytixmage-api.service -f # # Edit User / WorkingDirectory / EnvironmentFile / paths to match the server. # # Companion workers (already running as separate units): # python magento_worker.py # x4 # python -m app.jobs.channel_job_worker # python -m app.jobs.master_taxonomy_job_worker # python -m app.jobs.refresh_channel_readiness --poll 60 [Unit] Description=PlytixMage API (uvicorn) After=network-online.target postgresql.service Wants=network-online.target [Service] Type=simple User=homesurplus Group=homesurplus WorkingDirectory=/home/homesurplus/PlytixMage Environment=PYTHONUNBUFFERED=1 Environment=PATH=/home/homesurplus/PlytixMage/.venv/bin:/usr/bin # Optional: EnvironmentFile=-/home/homesurplus/PlytixMage/.env # HTTP concurrency (separate OS processes). Use 1 on memory-tight shared hosts # (server3: MariaDB + OpenSearch + Magento workers). 2+ only when free RAM/swap # are healthy — otherwise children die right after "Application startup complete". Environment=UVICORN_WORKERS=1 Environment=UVICORN_HOST=127.0.0.1 Environment=PORT=39810 Environment=UVICORN_RELOAD=false # Never run job daemons inside the API when standalone workers exist. Environment=MAGENTO_SYNC_WORKER_ENABLED=false Environment=CHANNEL_JOB_WORKER_ENABLED=false Environment=PLYTIX_WORKER_ENABLED=false Environment=CHANNEL_READINESS_WORKER_ENABLED=false # Uses main.py __main__ → uvicorn with UVICORN_* / PORT above. ExecStart=/home/homesurplus/PlytixMage/.venv/bin/python main.py Restart=always RestartSec=5 StandardOutput=journal StandardError=journal [Install] WantedBy=multi-user.target