Skip to content

Commit 7f6decd

Browse files
committed
Turn on swap during deployment to avoid out-of-memory in prisma migrate deploy.
Thanks to https://community.fly.io/t/prisma-sqlite-causes-an-out-of-memory-error-on-deploy/11039 for the instructions.
1 parent 49d68d5 commit 7f6decd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

webserver/fly-release-command.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { execSync } from 'node:child_process';
22
import { replaceDbWithBackup } from './replaceDbWithBackup.mjs';
33

4+
// Turn on swap to avoid out-of-memory errors during `prisma migrate deploy`
5+
console.log(execSync('fallocate -l 256M /swapfile', {encoding: 'utf-8'}));
6+
console.log(execSync('chmod 0600 /swapfile', {encoding: 'utf-8'}));
7+
console.log(execSync('mkswap /swapfile', {encoding: 'utf-8'}));
8+
console.log(execSync('echo 10 > /proc/sys/vm/swappiness', {encoding: 'utf-8'}));
9+
console.log(execSync('swapon /swapfile', {encoding: 'utf-8'}));
10+
411
if (process.env.FLY_APP_NAME === 'vlach-cookbook-staging') {
512
// Copy the latest backup over the staging database before running the Prisma
613
// migration, to make sure the migration will work when the app is released.

0 commit comments

Comments
 (0)