Skip to content

Deployment

Container

The EMS runs in ems-backend with the project at /app/es100cx12s and logs in /app/logs.

start_ems_client_in_docker.sh starts these processes:

Process Script Role
ems_http_api ems_settings_api.py server HTTP API for the frontend
ems_settings_poll ems_settings_api.py poll Pull settings every 5 seconds
sync_ems_control_setting file_sync.py Shared-folder settings sync
sync_lastvalues folder_sync.py Publish last values
folder_cleaner folder_cleaner.py Periodic cleanup
pcs_client pcs_client_save_data_v18_ES100CX12S.py PCS polling
grid_meter_client gridMeter_client_save_data_v11.py Grid meter polling
solar_meter_client solarMeter_client_save_data_v11.py Solar meter polling
ems_main ems_main.py Control loop

Each process writes its own log in /app/logs. The script exits if any process fails to start.

Environment variables

Variable Purpose Default
EMS_SETTINGS_API_TOKEN Bearer token for the HTTP API empty, authentication disabled
EMS_SETTINGS_API_PORT HTTP API port 8080
MODBUS_MODE SIM or RTU SIM
LOG_DIR Log directory /app/logs

EMS_SETTINGS_API_TOKEN must match EMS_BACKEND_TOKEN in the Laravel container.

Networking

ems-backend and ems-frontend must share a Docker network. The HTTP API binds to 0.0.0.0 inside the container. Port 8080 only needs to be reachable from Laravel, not from the public internet.

Outbound access

The settings pull targets the ems-frontend container over the Docker network, so no outbound internet access is required. ems-backend must be able to resolve and reach ems-frontend on port 80. If it cannot, the backend keeps serving the last cached settings and logs a warning every cycle.

Verifying a deployment

curl -H "Authorization: Bearer $EMS_SETTINGS_API_TOKEN" \
  http://ems-backend:8080/api/v1/ems/health

curl -H "Authorization: Bearer $EMS_SETTINGS_API_TOKEN" \
  http://ems-backend:8080/api/v1/ems/readings

Check that the pull is running:

tail -f /app/logs/ems_settings_poll.log
ls -l ems_pull_setting/

The timestamps in ems_pull_setting/ should advance every 5 seconds.