WIP. A little custom music server
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: run sync every 3 minutes

+5 -6
+5 -6
backend/src/index.ts
··· 1 1 import { BunContext, BunRuntime } from "@effect/platform-bun"; 2 - import { Config, Cron, Deferred, Effect, Either, Fiber, Layer, Option, Schedule } from "effect"; 2 + import { Config, Deferred, Effect, Fiber, Layer, Schedule } from "effect"; 3 3 import { drizzle } from "drizzle-orm/bun-sqlite"; 4 4 import { migrate } from "drizzle-orm/bun-sqlite/migrator"; 5 5 import { Database } from "bun:sqlite"; ··· 15 15 Layer.provideMerge(BunContext.layer), 16 16 Layer.merge(OtelLive), 17 17 ); 18 - 19 - const syncCron = Cron.parse("*/1 * * * *").pipe(Either.getRight, Option.getOrThrow); 20 - const syncSchedule = Schedule.cron(syncCron); 21 18 22 19 const SHUTDOWN_TIMEOUT_MS = 10_000; 23 20 ··· 55 52 56 53 yield* setupShutdownHandlers; 57 54 58 - // Start library sync in the background 59 - const syncFiber = yield* Effect.fork(syncLibraryStream(folderPath)); 55 + // Start library sync in the background, repeating every 10 minutes 56 + const syncFiber = yield* Effect.fork( 57 + syncLibraryStream(folderPath).pipe(Effect.repeat(Schedule.spaced("3 minutes"))), 58 + ); 60 59 61 60 // Wait for shutdown signal 62 61 yield* Deferred.await(shutdownSignal);