Service automatic re-initialization

Hi,

I ran Memos on Fly.io, but when it’s deployed, every 5 to 10 minutes the service is auto re-initialized, so I have to register a new admin account.

Same deployment on my VPS ran well. Is this a issue with Fly.io?

Hi @Ziwen! I’m not familiar with that app, but from the README it looks like it uses /var/opt/memos as a data directory. Have you created a volume and mounted it at that path?

(The root filesystem of a Fly VM is ephemeral and gets rebuilt from your app’s container image every time it starts; see here.)

Thank you Matthew! I did forget to check that parameter. Now I created a volume named memos_data and write it into fly.toml like this

[mounts]
source="memos_data"
destination="/var/opt/memos"

But after fly deploy, there was another error Error: Process group 'app' needs volumes with name 'memos_data' to fullfill mounts defined in fly.toml; Run fly volume create memos_data -r REGION for the following regions and counts: sjc=1. Also, the Attached VM is blank when running fly volumes list.

Would you please help me with that if convenient? Thanks in advance.

Facing the same issue here while trying to follow @kentcdodds tutorial.

In this specific step: Persist Application Data Between Deployments | Epic Web Dev by Kent C. Dodds

If you follow the steps documented in Add volume storage · Fly Docs, then it should work.

In summary, execute these steps in this exact order:

  1. Launch app without deploying: fly launch
  2. Add mounts entry to fly.toml;
        [mounts]
            source="memos_data"
            destination="/var/opt/memos"
    
  3. Deploy app: fly deploy

A volume with the name you specified, will be created and attached to your app.

I still didn’t understand why trying to attach the volume after the app is deployed do not work. This is what @kentcdodds does here: Persist Application Data Between Deployments | Epic Web Dev by Kent C. Dodds and it worked for him.

I found another related post here that might help if you want to attach a volume to a running app. I did not dig into that, nor tried to reproduce, but here it is:

Cheers!

Hi @Ziwen and @amaralc

We’ve just added some functionality to add volumes to existing apps and are in the process of updating the docs.

You’ll need to have flyctl v0.0.548 or higher to do this.

  1. Add the mounts section to your fly.toml with the volume name and destination directory:

    [mounts]
    source=“memos_data”
    destination=“/var/opt/memos”

  2. Create the volume (or volumes!) with the name from the fly.toml in the same region as your app.

    fly volume create memos_data -r sjc

    Note that you need to create as many volumes as you have machines per process in your app. (For new apps, fly launch creates 2 machines now by default.)

    The error that you get when you have [mounts] configured, but you don’t have enough (or any) volumes, tells you what’s required. In @Ziwen’s example above, it shows sjc=1, so you would create one volume in the sjc region.

  3. Run fly deploy.

You can run fly volumes list and you should see that your volume, or volumes, have ATTACHED VM populated now.

Let us know if you run into any problems!

2 Likes

Thanks again! That worked for me and it’s happy to start with Fly.io!

3 Likes

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