Skip to content

Commit

Permalink
implement WAL more properly
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Feb 27, 2024
1 parent 36a10bd commit f818b22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ ENV DATABASE_URL="file:$DATABASE_PATH"
ENV INTERNAL_PORT="8080"
ENV PORT="8081"
ENV NODE_ENV="production"
# For WAL support: https://github.com/prisma/prisma-engines/issues/4675#issuecomment-1914383246
ENV PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK = "1"
# ENV DISABLE_METRONOME="true"
ENV CACHE_DATABASE_FILENAME="cache.db"
ENV CACHE_DATABASE_PATH="$LITEFS_DIR/$CACHE_DATABASE_FILENAME"
Expand All @@ -81,7 +83,7 @@ COPY --from=build /app/server-build /app/server-build
ADD . .

# prepare for litefs
COPY --from=flyio/litefs:0.5.10 /usr/local/bin/litefs /usr/local/bin/litefs
COPY --from=flyio/litefs:0.5.11 /usr/local/bin/litefs /usr/local/bin/litefs
ADD other/litefs.yml /etc/litefs.yml
RUN mkdir -p /data ${LITEFS_DIR}

Expand Down
8 changes: 5 additions & 3 deletions other/litefs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ lease:
exec:
- cmd: node ./other/setup-swap.js

- cmd: sqlite3 $DATABASE_PATH "PRAGMA journal_mode = WAL;"
- cmd: npx prisma migrate deploy
if-candidate: true

- cmd: sqlite3 $CACHE_DATABASE_PATH "PRAGMA journal_mode = WAL;"
# Set the journal mode for the database to WAL. This reduces concurrency deadlock issues
- cmd: sqlite3 $DATABASE_PATH "PRAGMA journal_mode = WAL;"
if-candidate: true

- cmd: npx prisma migrate deploy
# Set the journal mode for the cache to WAL. This reduces concurrency deadlock issues
- cmd: sqlite3 $CACHE_DATABASE_PATH "PRAGMA journal_mode = WAL;"
if-candidate: true

- cmd: npm start

0 comments on commit f818b22

Please sign in to comment.