@@ -22,6 +22,7 @@ export interface WorkerConfig {
2222 workerPort : number
2323 quoteServicePort : number
2424 bundleDir : string
25+ dbDir ?: string
2526}
2627
2728export interface WorkerResult {
@@ -34,7 +35,7 @@ export interface WorkerResult {
3435export async function startWorker (
3536 options : WorkerConfig ,
3637) : Promise < WorkerResult > {
37- const { workerPort, quoteServicePort, bundleDir } = options
38+ const { workerPort, quoteServicePort, bundleDir, dbDir } = options
3839 const quoteServiceUrl = `http://127.0.0.1:${ quoteServicePort } `
3940
4041 const WORKER_JS = "worker.js"
@@ -54,8 +55,16 @@ export async function startWorker(
5455 mkdirSync ( staticDir , { recursive : true } )
5556 }
5657
57- // Create temp directory for Durable Object SQLite storage
58- const doStorageDir = mkdtempSync ( join ( tmpdir ( ) , "kettle-do-storage-" ) )
58+ // Use provided db directory or create temp directory for Durable Object SQLite storage
59+ let doStorageDir : string
60+ if ( dbDir ) {
61+ doStorageDir = dbDir
62+ if ( ! existsSync ( doStorageDir ) ) {
63+ mkdirSync ( doStorageDir , { recursive : true } )
64+ }
65+ } else {
66+ doStorageDir = mkdtempSync ( join ( tmpdir ( ) , "kettle-do-storage-" ) )
67+ }
5968
6069 // Start quote service
6170 const quoteService = startQuoteService ( quoteServicePort )
@@ -297,6 +306,7 @@ const config :Workerd.Config = (
297306export interface StartWorkerArgs {
298307 file ?: string
299308 port ?: number
309+ dbDir ?: string
300310}
301311
302312export async function startWorkerCommand ( argv : StartWorkerArgs ) {
@@ -323,6 +333,7 @@ export async function startWorkerCommand(argv: StartWorkerArgs) {
323333 workerPort : port ,
324334 quoteServicePort : await findFreePort ( ) ,
325335 bundleDir : join ( projectDir , "dist" ) ,
336+ dbDir : argv . dbDir ,
326337 } )
327338
328339 process . on ( "SIGINT" , ( ) => stop ( ) )
0 commit comments