Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,17 @@ export const configSchema = {
properties: {
rebalanceEnabled: { type: "boolean" },
swapEnabled: { type: "boolean" },
// Gates the upstream-galoy LND/bitcoin maintenance tasks in the cron
// server. Flash runs IBEX-custodial with no LND, so deployments set
// this false; defaults true for upstream parity.
lndTasksEnabled: { type: "boolean", default: true },
},
required: ["rebalanceEnabled", "swapEnabled"],
additionalProperties: false,
default: {
rebalanceEnabled: true,
swapEnabled: true,
lndTasksEnabled: true,
},
},
captcha: {
Expand Down
1 change: 1 addition & 0 deletions src/config/schema.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ type YamlSchema = {
cronConfig: {
rebalanceEnabled: boolean
swapEnabled: boolean
lndTasksEnabled: boolean
}
captcha: {
mandatory: boolean
Expand Down
1 change: 1 addition & 0 deletions src/config/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Levels = number[]
type CronConfig = {
rebalanceEnabled: boolean
swapEnabled: boolean
lndTasksEnabled: boolean
}

type CaptchaConfig = {
Expand Down
42 changes: 30 additions & 12 deletions src/servers/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,45 @@ const reconcileBridgeWithdrawalsJob = async () => {
const main = async () => {
console.log("cronjob started")
const start = new Date()
await checkAllLndHealth()

const cronConfig = getCronConfig()

// Flash runs IBEX-custodial with no LND nodes, so the upstream-galoy
// LND/bitcoin maintenance tasks have nothing to operate on — worse, the
// ones that require a reachable node throw OffChainServiceUnavailableError,
// failing the whole run (exit 99 → CrashLoopBackOff on the k8s Job).
// lndTasksEnabled (default true, for upstream parity) lets deployments
// without LND run only the tasks that apply: mongo expiry cleanup and
// Bridge↔IBEX reconciliation.
if (cronConfig.lndTasksEnabled) {
await checkAllLndHealth()
}

const results: Array<boolean> = []
const mongoose = await setupMongoConnection()

const tasks = [
// bitcoin related tasks
rebalancingInternalChannels,
updateEscrows,
updatePendingLightningInvoices,
updatePendingLightningPayments,
updateLnPaymentsCollection,
updateRoutingRevenues,
updateLegacyOnChainReceipt,
// bitcoin/LND tasks — upstream galoy; require LND to do anything useful
...(cronConfig.lndTasksEnabled
? [
rebalancingInternalChannels,
updateEscrows,
updatePendingLightningInvoices,
updatePendingLightningPayments,
updateLnPaymentsCollection,
updateRoutingRevenues,
updateLegacyOnChainReceipt,
]
: []),
...(cronConfig.rebalanceEnabled ? [rebalance] : []),
...(cronConfig.swapEnabled ? [swapOutJob] : []),
reconcileBridgeDepositsJob,
reconcileBridgeWithdrawalsJob,
deleteExpiredPaymentFlows,
deleteExpiredInvoices,
deleteLndPaymentsBefore2Months,
deleteFailedPaymentsAttemptAllLnds,
...(cronConfig.lndTasksEnabled
? [deleteLndPaymentsBefore2Months, deleteFailedPaymentsAttemptAllLnds]
: []),
]

const PROCESS_KILL_EVENTS = ["SIGTERM", "SIGINT"]
Expand Down Expand Up @@ -198,7 +214,9 @@ const main = async () => {
}

try {
activateLndHealthCheck()
if (getCronConfig().lndTasksEnabled) {
activateLndHealthCheck()
}
main()
} catch (err) {
logger.warn({ err }, "error in the cron job")
Expand Down
Loading