Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(tasks): allow disabling scheduled tasks on startup globally (#1121)

Corentin Thomasset3a675076877e
diff --git a/.changeset/fancy-bottles-call.md b/.changeset/fancy-bottles-call.md
new file mode 100644
index 00000000..2cb51edf
--- /dev/null
+++ b/.changeset/fancy-bottles-call.md
@@ -0,0 +1,5 @@
+---
+"@papra/app": patch
+---
+
+Added the possibility to disable the initial startup execution of all scheduled tasks by setting the `RUN_SCHEDULED_TASKS_ON_STARTUP_DEFAULT=false` environment variable, mainly usefull for instance that reboot often, dev environments or fast startup requirements (few ms gained). Each task startup configuration remain individually configurable with their dedicated environment variable.
diff --git a/apps/papra-server/src/modules/tasks/tasks.config.ts b/apps/papra-server/src/modules/tasks/tasks.config.ts
index 1c7fc715..176ebe19 100644
--- a/apps/papra-server/src/modules/tasks/tasks.config.ts
+++ b/apps/papra-server/src/modules/tasks/tasks.config.ts
@@ -5,6 +5,8 @@ import { coercedPositiveIntegerSchema } from '../shared/schemas/number.schemas';
import { IN_MS } from '../shared/units';
import { tasksDriverNames } from './drivers/tasks-driver.constants';
+const RUN_ALL_SCHEDULED_TASKS_ON_STARTUP_ENV = 'RUN_SCHEDULED_TASKS_ON_STARTUP_DEFAULT';
+
export const tasksConfig = {
persistence: {
driverName: {
@@ -60,7 +62,7 @@ export const tasksConfig = {
doc: 'Whether the task to hard delete expired "soft deleted" documents should run on startup',
schema: booleanishSchema,
default: true,
- env: 'DOCUMENTS_HARD_DELETE_EXPIRED_DOCUMENTS_RUN_ON_STARTUP',
+ env: ['DOCUMENTS_HARD_DELETE_EXPIRED_DOCUMENTS_RUN_ON_STARTUP', RUN_ALL_SCHEDULED_TASKS_ON_STARTUP_ENV],
},
},
expireInvitations: {
@@ -74,7 +76,7 @@ export const tasksConfig = {
doc: 'Whether the task to expire invitations should run on startup',
schema: booleanishSchema,
default: true,
- env: 'ORGANIZATIONS_EXPIRE_INVITATIONS_RUN_ON_STARTUP',
+ env: ['ORGANIZATIONS_EXPIRE_INVITATIONS_RUN_ON_STARTUP', RUN_ALL_SCHEDULED_TASKS_ON_STARTUP_ENV],
},
},
purgeExpiredOrganizations: {
@@ -88,7 +90,7 @@ export const tasksConfig = {
doc: 'Whether the task to purge expired soft-deleted organizations should run on startup',
schema: booleanishSchema,
default: true,
- env: 'ORGANIZATIONS_PURGE_EXPIRED_ORGANIZATIONS_RUN_ON_STARTUP',
+ env: ['ORGANIZATIONS_PURGE_EXPIRED_ORGANIZATIONS_RUN_ON_STARTUP', RUN_ALL_SCHEDULED_TASKS_ON_STARTUP_ENV],
},
},
purgeExpiredKvEntries: {
@@ -102,7 +104,7 @@ export const tasksConfig = {
doc: 'Whether the task to purge expired key-value store entries should run on startup',
schema: booleanishSchema,
default: true,
- env: 'KV_STORE_PURGE_EXPIRED_ENTRIES_RUN_ON_STARTUP',
+ env: ['KV_STORE_PURGE_EXPIRED_ENTRIES_RUN_ON_STARTUP', RUN_ALL_SCHEDULED_TASKS_ON_STARTUP_ENV],
},
},
} as const satisfies ConfigDefinition;