ToolJet/docker/pre-release/ee/ee-entrypoint.sh
Akshay 18b831f783
Refactor: Workflows with BullMQ (#14275)
* refactor(workflows): migrate core modules from Temporal to BullMQ

Update main application modules to support BullMQ-based workflow scheduling:

- Remove Temporal worker bootstrap code from main.ts
- Migrate from @nestjs/bull to @nestjs/bullmq
- Add Bull Board dashboard at /jobs with basic auth
- Register BullMQ queues in WorkflowsModule
- Add IWorkflowScheduler interface for scheduler abstraction
- Create CE stubs for WorkflowSchedulerService and ScheduleBootstrapService
- Remove workflow dependencies from AppsModule (moved to WorkflowsModule)
- Add proper route exclusion for /jobs dashboard
- Support WORKER env var for conditional processor registration

This commit completes the migration from Temporal to BullMQ for workflow
scheduling, enabling simpler deployment and better horizontal scaling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: remove unused Temporal imports and commented code

Clean up migration artifacts:
- Remove unused imports from main.ts (TOOLJET_EDITIONS, getImportPath, ITemporalService, getTooljetEdition)
- Remove commented TemporalService references from WorkflowsModule
- Remove temporal.service from getProviders path array
- Add missing newlines at EOF for IWorkflowScheduler.ts and schedule-bootstrap.service.ts

This cleanup prepares the codebase for complete Temporal code removal in a future commit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* build: add BullMQ and Bull Board dependencies

Add required packages for BullMQ-based workflow scheduling:

- @nestjs/bullmq: NestJS integration for BullMQ
- @bull-board/api, @bull-board/express, @bull-board/nestjs: Queue dashboard
- bullmq: Core BullMQ library
- express-basic-auth: Authentication for Bull Board dashboard

Note: @nestjs/bull is kept for backward compatibility during migration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: remove Temporal service files from CE

Remove deprecated Temporal-based workflow implementation files:
- server/src/modules/workflows/interfaces/ITemporalService.ts
- server/src/modules/workflows/services/temporal.service.ts

These files are replaced by IWorkflowScheduler interface and BullMQ-based
WorkflowSchedulerService implementation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add comprehensive Redis configuration support for BullMQ

* refactor: remove Temporal setup and configuration from entrypoint scripts and Dockerfiles (#14294)

* refactor: remove Temporal setup and configuration from entrypoint scripts and Dockerfiles

* feat: integrate Redis support for BullMQ in preview environment

* remove worker execution logic from setup script

* Refactor: Centralise workflow execution through BullMQ (#14321)

* refactor: run all workflows through bullmq

* refactor: update imports

* chore: update subproject commit reference in server/ee

* feat: ablity to cancel workflow

* feat: implement workflow cancellation functionality with Redis support

* feat: add optional timeout parameter to requestCancellation method

* refactor: clean up formatting and add maintenance toggle event emission in AppsService

* feat: ability to cancel multiple inprogress executions

* feat: implement execution state management and display logic

* chore: update submodule commit reference

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Adish M <44204658+adishM98@users.noreply.github.com>
2025-11-05 17:54:38 +05:30

67 lines
2 KiB
Bash
Executable file

#!/bin/bash
set -e
npm cache clean --force
# Load environment variables from .env if the file exists
if [ -f "./.env" ]; then
export $(grep -v '^#' ./.env | xargs -d '\n') || true
fi
# Start Redis server only if REDIS_HOST is localhost or not set
if [ -z "$REDIS_HOST" ] || [ "$REDIS_HOST" = "localhost" ]; then
echo "Starting Redis server locally..."
redis-server /etc/redis/redis.conf &
elif [ -n "$REDIS_URL" ]; then
echo "REDIS_URL connection is set: $REDIS_URL"
else
echo "Using external Redis at $REDIS_HOST:$REDIS_PORT."
# Validate external Redis connection
if ! ./server/scripts/wait-for-it.sh "$REDIS_HOST:${REDIS_PORT:-6379}" --strict --timeout=300 -- echo "Redis is up"; then
echo "Error: Unable to connect to Redis at $REDIS_HOST:$REDIS_PORT."
exit 1
fi
fi
# Check if PGRST_HOST starts with "localhost"
if [[ "$PGRST_HOST" == localhost:* ]]; then
echo "Starting PostgREST server locally..."
# Generate PostgREST configuration in a writable directory
POSTGREST_CONFIG_PATH="/tmp/postgrest.conf"
echo "db-uri = \"${PGRST_DB_URI}\"" > "$POSTGREST_CONFIG_PATH"
echo "db-pre-config = \"postgrest.pre_config\"" >> "$POSTGREST_CONFIG_PATH"
echo "server-port = \"${PGRST_SERVER_PORT}\"" >> "$POSTGREST_CONFIG_PATH"
# Starting PostgREST
echo "Starting PostgREST..."
postgrest "$POSTGREST_CONFIG_PATH" &
else
echo "Using external PostgREST at $PGRST_HOST."
fi
# Determine setup command based on the presence of ./server/dist
if [ -d "./server/dist" ]; then
SETUP_CMD='npm run db:setup:prod'
else
SETUP_CMD='npm run db:setup'
fi
# Wait for PostgreSQL connection
if [ -z "$DATABASE_URL" ]; then
./server/scripts/wait-for-it.sh $PG_HOST:${PG_PORT:-5432} --strict --timeout=300 -- echo "PostgreSQL is up"
else
PG_HOST=$(echo "$DATABASE_URL" | awk -F'[/:@?]' '{print $6}')
PG_PORT=$(echo "$DATABASE_URL" | awk -F'[/:@?]' '{print $7}')
./server/scripts/wait-for-it.sh "$PG_HOST:$PG_PORT" --strict --timeout=300 -- echo "PostgreSQL is up"
fi
# Run setup command if defined
if [ -n "$SETUP_CMD" ]; then
$SETUP_CMD
fi
exec "$@"