register all cron jobs in entrypoint (#12791)
closes https://github.com/twentyhq/core-team-issues/issues/1113 Three things I am not sure about - - Should we have a variable just like DISABLE_DB_MIGRATIONS to control cron job registration behavior, i.e., DISABLE_CRON_JOBS_REGISTRATION? - The location of the command ie, folder placement - https://github.com/twentyhq/twenty/pull/12791/files#r2161734131
This commit is contained in:
@ -12,6 +12,8 @@ services:
|
||||
PG_DATABASE_URL: postgres://${PG_DATABASE_USER:-postgres}:${PG_DATABASE_PASSWORD:-postgres}@${PG_DATABASE_HOST:-db}:${PG_DATABASE_PORT:-5432}/default
|
||||
SERVER_URL: ${SERVER_URL}
|
||||
REDIS_URL: ${REDIS_URL:-redis://redis:6379}
|
||||
DISABLE_DB_MIGRATIONS: ${DISABLE_DB_MIGRATIONS}
|
||||
DISABLE_CRON_JOBS_REGISTRATION: ${DISABLE_CRON_JOBS_REGISTRATION}
|
||||
|
||||
STORAGE_TYPE: ${STORAGE_TYPE}
|
||||
STORAGE_S3_REGION: ${STORAGE_S3_REGION}
|
||||
@ -63,6 +65,7 @@ services:
|
||||
SERVER_URL: ${SERVER_URL}
|
||||
REDIS_URL: ${REDIS_URL:-redis://redis:6379}
|
||||
DISABLE_DB_MIGRATIONS: "true" # it already runs on the server
|
||||
DISABLE_CRON_JOBS_REGISTRATION: "true" # it already runs on the server
|
||||
|
||||
STORAGE_TYPE: ${STORAGE_TYPE}
|
||||
STORAGE_S3_REGION: ${STORAGE_S3_REGION}
|
||||
|
||||
@ -28,7 +28,23 @@ setup_and_migrate_db() {
|
||||
yarn command:prod upgrade
|
||||
echo "Successfully migrated DB!"
|
||||
}
|
||||
|
||||
register_background_jobs() {
|
||||
if [ "${DISABLE_CRON_JOBS_REGISTRATION}" = "true" ]; then
|
||||
echo "Cron job registration is disabled, skipping..."
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Registering background sync jobs..."
|
||||
if yarn command:prod cron:register:all; then
|
||||
echo "Successfully registered all background sync jobs!"
|
||||
else
|
||||
echo "Warning: Failed to register background jobs, but continuing startup..."
|
||||
fi
|
||||
}
|
||||
|
||||
setup_and_migrate_db
|
||||
register_background_jobs
|
||||
|
||||
# Continue with the original Docker command
|
||||
exec "$@"
|
||||
|
||||
Reference in New Issue
Block a user