Background Services

When to run the automations and logs services alongside the APIs. This guide follows version 3.1.7 (03acdf712c).

For local startup, see Local Setup. For log inspection, see Logs & Troubleshooting.

Services

  • Automations: backend/services/automations/src/main.ts, listens on PORT || 3302, registers erxes-service-automations in Redis, then starts BullMQ workers for trigger, action, and aiAgent queues.
  • Logs: backend/services/logs/src/main.ts, listens on PORT || 3301, registers erxes-service-logs, then starts eventLog, activityLog, and segment workers.

Both resolve tenant models per subdomain (connectionResolver.ts / connectionResolvers.ts) and use Redis-backed queues via backend/erxes-api-shared/src/utils/mq-worker.ts. The logs service persists to a separate database named <application-database>_logs (for example erxes_logs).

Enabling services locally

scripts/start-api-dev.js reads ENABLED_PLUGINS, ENABLED_PLUGINS_ONLY_API, and ENABLED_SERVICES, then runs nx run-many -t serve -p core-api <plugins/services> gateway.

ENABLED_PLUGINS=sales
ENABLED_SERVICES=automations,logs

Enable automations when working with automation execution and logs when working with persisted activity/event logs and the automatic undo journal. Restart pnpm dev:apis after changing the list.

Production notes

CI publishes erxes/erxes-next-automations and erxes/erxes-next-logs images alongside the API images. Deploy the services your workload needs; a gateway plus Core API alone does not execute automation or persist logs workers.

Source references

Was this helpful?