Deployment And Testing
Docker environment
Both services must be on the same Docker network and use these service names:
ems-frontend Laravel application
ems-backend Python EMS application
The Python service listens on 0.0.0.0:8080 inside the container. Laravel uses:
http://ems-backend:8080
The browser uses Laravel's own host and routes, not the Python container name.
Required environment values
Laravel:
EMS_BACKEND_URL=http://ems-backend:8080
EMS_BACKEND_TOKEN=replace-with-a-long-random-token
EMS_BACKEND_TIMEOUT=10
Python EMS:
EMS_SETTINGS_API_TOKEN=replace-with-a-long-random-token
EMS_SETTINGS_API_PORT=8080
EMS_BACKEND_TOKEN and EMS_SETTINGS_API_TOKEN must match exactly.
Laravel cache reset
Run inside ems-frontend after changing .env or config/services.php:
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan route:list --path=api/ems
If production config is cached, rebuild it after confirming the environment values:
php artisan config:cache
php artisan route:cache
Test from inside the Laravel container
Health check:
curl -i \
-H "Authorization: Bearer ${EMS_BACKEND_TOKEN}" \
-H "Accept: application/json" \
http://ems-backend:8080/api/v1/ems/health
Read settings:
curl -i \
-H "Authorization: Bearer ${EMS_BACKEND_TOKEN}" \
-H "Accept: application/json" \
http://ems-backend:8080/api/v1/ems/settings
Read telemetry:
curl -i \
-H "Authorization: Bearer ${EMS_BACKEND_TOKEN}" \
-H "Accept: application/json" \
http://ems-backend:8080/api/v1/ems/readings
Test the Laravel proxy from outside:
curl -i -H "Accept: application/json" \
https://your-frontend-host/api/ems/health
Test a settings update
Use a complete settings file. Do not test with a partial object against a production EMS instance.
curl -i -X PUT \
-H "Authorization: Bearer ${EMS_BACKEND_TOKEN}" \
-H "Content-Type: application/json" \
--data-binary @full-ems-control-settings.json \
http://ems-backend:8080/api/v1/ems/settings
Then verify that the EMS JSON file and the shared-folder mirror contain the updated ems_operation_mode. The EMS dispatcher will use it on its next cycle.
Troubleshooting
Could not resolve host: ems-backend
Laravel and Python are not attached to the same Docker network, or the service name differs from ems-backend.
401 Unauthorized
Compare EMS_BACKEND_TOKEN in Laravel with EMS_SETTINGS_API_TOKEN in Python. Remove whitespace and restart/reload the containers.
502 ems_backend_unavailable
Check the Python process log and confirm port 8080 is listening inside ems-backend:
docker exec ems-backend sh -c 'python3 - <<"PY"
import urllib.request
print(urllib.request.urlopen("http://127.0.0.1:8080/api/v1/ems/health").read().decode())
PY'
Settings revert after saving
Confirm that the Python API is mirroring writes to the shared-folder source and that the old file_sync.py process is not copying a stale file from another source. Check timestamps on both settings files.
Readings are empty
The API only exposes JSON files currently present in Python's lastValue/ directory. Confirm the collectors are running and updating those files.