LiteFS with more than one ProcessGroup


I’m currently using litefs/litefs cloud in a web application. Now, I need to add another process group to my app for a particular set of worker machines (which periodically process newly uploaded images). This process is CPU-intensive, and I want to isolate it from the primary web service.

I have a process group named app, and now a new one named work. I’ve specified that the workers should never become the primary using the following condition

candidate: ${FLY_REGION == PRIMARY_REGION && FLY_PROCESS_GROUP == "app"}  

This ensures that the workers only get read access to the database, i can work with that.

However, the application gets started from litefs with the following command:

  - cmd: "npm run start"  

ISSUE: litefs needs to start different long-running processes depending on whether it is a worker or the web-app. How should I go about configuring that?

Please let me know if there are other mistakes in my plain :slight_smile:

Your best bet is to either set the exec.cmd with an environment variable or to use separate litefs.yml configs. In your process group, you can define small wrapper scripts and set the environment variables there:

app = ""
work = ""

and then define your variable in there:

export LITEFS_EXEC_CMD = "npm run start"
exec litefs mount

and then use that variable in your litefs.yml:

  - cmd: "${LITEFS_EXEC_CMD}"
1 Like

Nice! Thanks i will try that, looks good!

I did something really similar, except I referenced a different LiteFS file name. The reason I set mine up with files is because I didn’t want one of the process groups from ever becoming the candidate, but I did want the other.

This could of been more ENV variables though.

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