Comments (11)
There is a related issue on the fly.io community: Prisma + SQLite causes an out of memory error on deploy which references the following fly.io docs page Optimizing your deployment.
As far as I understand if you turn on swap mode before running migrations, it will use disk space instead of running out of memory. Removing the swap directory and disabling swap after running migrations also seems reasonable to me.
The modified start.sh
file would then look somewhat like this.
#!/bin/sh
# This file is how Fly starts the server (configured in fly.toml). Before starting
# the server though, we need to run any prisma migrations that haven't yet been
# run, which is why this file exists in the first place.
# Learn more: https://community.fly.io/t/sqlite-not-getting-setup-properly/4386
set -ex
# Setup 512MB of space for swap and set permissions and turn on swapmode
fallocate -l 512M /swapfile
chmod 0600 /swapfile
mkswap /swapfile
echo 10 > /proc/sys/vm/swappiness
swapon /swapfile
# Run migrations
npx prisma migrate deploy
# Turn off swap mode and remove swap directory
swapoff /swapfile
rm /swapfile
# Finally start the app
npm run start
Can anyone try this out?
from indie-stack.
I'm also experiencing this. It's not ideal.
I was able to deploy reliably after the first revision by moving prisma
from devDependencies
into dependencies
.
from indie-stack.
@hilja Nice π I wonβt have time to test it myself for the next few weeks with Sqlite but once I have, Iβll create a pull request.
from indie-stack.
nice find @Apsysikal, if this does fix the problem, more than happy to accept a PR π
from indie-stack.
@Apsysikal -- you're my hero, thank you π
from indie-stack.
By the way, this seems to be a duplicate of #156 but that one is closed since the author opted to stopped using Fly, so probably that one is untracked.
from indie-stack.
This just happened to me on a fresh newly created app (today). I can confirm that the above comment from @seashairo helped me get it working.
from indie-stack.
@Apsysikal I tested the swap and it worked great. It was on a postgress instance tho.
from indie-stack.
I was having this issue with a completely fresh npx create-remix@latest using Sqlite and it fixed it for me :)
2023-03-31T16:35:54.755 app[9185900a4e3978] lhr [info] + npx prisma migrate deploy
2023-03-31T16:35:56.832 app[9185900a4e3978] lhr [info] npm WARN exec The following package was not found and will be installed: [email protected]
2023-03-31T16:36:00.514 app[9185900a4e3978] lhr [info] [ 5.916011] Out of memory: Killed process 597 (node) total-vm:11112664kB, anon-rss:108160kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:1160kB oom_score_adj:0
2023-03-31T16:36:00.543 app[9185900a4e3978] lhr [info] Killed
That was the error before and this was the result after:
2023-03-31T16:43:09.903 app[9185900a4e3978] lhr [info] Preparing to run: `./start.sh` as root
2023-03-31T16:43:09.939 app[9185900a4e3978] lhr [info] 2023/03/31 16:43:09 listening on [fdaa:1:cc1d:a7b:be65:789f:2041:2]:22 (DNS: [fdaa::3]:53)
2023-03-31T16:43:09.939 app[9185900a4e3978] lhr [info] + fallocate -l 512M /swapfile
2023-03-31T16:43:09.947 app[9185900a4e3978] lhr [info] + chmod 0600 /swapfile
2023-03-31T16:43:09.949 app[9185900a4e3978] lhr [info] + mkswap /swapfile
2023-03-31T16:43:09.977 app[9185900a4e3978] lhr [info] Setting up swapspace version 1, size = 512 MiB (536866816 bytes)
2023-03-31T16:43:09.977 app[9185900a4e3978] lhr [info] no label, UUID=d6e6b09e-ef48-4580-b278-cd989098c8e2
2023-03-31T16:43:09.980 app[9185900a4e3978] lhr [info] + echo 10
2023-03-31T16:43:09.980 app[9185900a4e3978] lhr [info] + swapon /swapfile
2023-03-31T16:43:09.992 app[9185900a4e3978] lhr [info] + npx prisma migrate deploy
2023-03-31T16:43:12.437 app[9185900a4e3978] lhr [info] npm WARN exec The following package was not found and will be installed: [email protected]
2023-03-31T16:43:18.141 app[9185900a4e3978] lhr [info] Prisma schema loaded from prisma/schema.prisma
2023-03-31T16:43:18.144 app[9185900a4e3978] lhr [info] Datasource "db": SQLite database "sqlite.db" at "file:/data/sqlite.db"
2023-03-31T16:43:18.281 app[9185900a4e3978] lhr [info] 1 migration found in prisma/migrations
2023-03-31T16:43:18.290 app[9185900a4e3978] lhr [info] No pending migrations to apply.
2023-03-31T16:43:18.399 app[9185900a4e3978] lhr [info] npm notice
2023-03-31T16:43:18.399 app[9185900a4e3978] lhr [info] npm notice New major version of npm available! 8.19.4 -> 9.6.3
2023-03-31T16:43:18.400 app[9185900a4e3978] lhr [info] npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.6.3>
2023-03-31T16:43:18.400 app[9185900a4e3978] lhr [info] npm notice Run `npm install -g [email protected]` to update!
2023-03-31T16:43:18.400 app[9185900a4e3978] lhr [info] npm notice
2023-03-31T16:43:18.440 app[9185900a4e3978] lhr [info] + swapoff /swapfile
2023-03-31T16:43:18.473 app[9185900a4e3978] lhr [info] + rm /swapfile
2023-03-31T16:43:18.480 app[9185900a4e3978] lhr [info] + npm run start
2023-03-31T16:43:19.008 app[9185900a4e3978] lhr [info] > start
2023-03-31T16:43:19.008 app[9185900a4e3978] lhr [info] > remix-serve build
2023-03-31T16:43:19.514 app[9185900a4e3978] lhr [info] Remix App Server started at http://localhost:8080 (http://172.19.133.250:8080)
2023-03-31T16:43:21.687 health[9185900a4e3978] lhr [info] Health check on port 8080 is now passing.
2023-03-31T16:43:23.103 app[9185900a4e3978] lhr [info] HEAD / 200 - - 29.662 ms
2023-03-31T16:43:23.125 app[9185900a4e3978] lhr [info] GET /healthcheck 200 - - 72.490 ms
from indie-stack.
@Apsysikal works like a charm! Thanks a lot π
I'm using Indie stack with LiteSQL
from indie-stack.
This will be fixed by #232
from indie-stack.
Related Issues (20)
- Failed app run HOT 3
- Missing Environment Variables when Prisma is removed HOT 3
- Env variables undefined in build but fine in dev HOT 1
- pnpm is not preinstalled and causes an error in Cypress HOT 3
- No region defined in the fly deploy command, causes deployment to crash HOT 10
- Remix and Cypress hydration problem HOT 7
- hydration failed,and css file will request twice HOT 1
- Error during deployment in Fly.io, Dockerfile needs to give permissons to `start.sh` script HOT 3
- Timeout when Running e2e tests on a fresh installation HOT 1
- Typecheck fails because it can't find definitions for cypress or @testing-library/cypress HOT 6
- throw new Error(`Failed to kill process ${pid}: ${error}`) after code change HOT 3
- Tailwind SourceMap/EsBuild Issue HOT 4
- Error upon deployment: you must be authenticated
- Cypress custom commands doesn't load HOT 2
- Use `fly launch`/`dockerfile-node` instead of `.dockerignore`, `Dockerfile`, `fly.toml` & `start.sh` HOT 9
- Deployment in Fly.io crashes with JavaScript heap out of memory HOT 5
- bun breaks deploy HOT 2
- Initial commit will not deploy HOT 11
- Using `remix-auth` in indie-stack HOT 1
- Error: Invariant failed: SESSION_SECRET must be set HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from indie-stack.