Persistent storage not working on express js app

So I set up my express app and deployed it successfully. I also set up persistent storage and mounted my app to it. However, there is the issue of data not being stored on the disk when the machine is offline. In my Dockerfile, I set up the WORKDIR as /app:


And mounted the storage to app-root:

  source = "storage_dir"
  destination = "/app-root"

If I change the mount to /app, I always get errors when running the app, specifically:

pm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/app/package.json'

ERROR error umounting /app: EBUSY: Device or resource busy, retrying in a bit

And only when I change it back to /app-root does the app work as expected. I am not sure what I should do at this point.

Hi @Bryan.YourCake

Could this be a case of your app not using the correct directory for persistent storage?

You can debug that by starting your app then using fly ssh console -a APP_NAME to navigate in your files to try to spot where they’re being created.

You definitely want to separate the place where the app is stored (/app) and the data storage folder (/app-root).

1 Like

You are absolutely right, the mistake I made was not creating the new dir within app-root where the files were stored. Now by creating this and pointing the files to the absolute path where they would be stored for future purposes, they became accessible and I could read and write from the persistent volume.

1 Like

Im glad its working now!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.