# Self Hosting PM2 Variables and Flows

**URL:** <https://community.directus.com/t/self-hosting-pm2-variables-and-flows/361>\
**Category:** Help\
**Created:** [May 20, 2025, 6:47am UTC](https://community.directus.com/t/self-hosting-pm2-variables-and-flows/361 "2025-05-20T06:47:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![samhallam](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@samhallam](https://community.directus.com/u/samhallam)\
**Post date:** [May 20, 2025, 6:47am UTC](https://community.directus.com/t/self-hosting-pm2-variables-and-flows/361/1 "2025-05-20T06:47:50Z")

</div>

I have recently implemented on a self hosted version of directus multiple PM2 instances using the PM2\_INSTANCES env variable, since then though directus flows that have on a scheduled chron-job are running multiple times in each instance which is causing all sorts of duplicate data.

Does anyone know a way to force flows to run in just one instance of the app when using PM2 in cluster mode with multiple instances?

---

<div class="post-metadata">

**Author:** ![bryantgillespie](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/bryantgillespie/32/33_2.png) [@bryantgillespie](https://community.directus.com/u/bryantgillespie)\
**Post date:** [May 21, 2025, 12:25pm UTC](https://community.directus.com/t/self-hosting-pm2-variables-and-flows/361/4 "2025-05-21T12:25:06Z")

</div>

Make sure that you Redis running, connected, and configured correctly.

Please see the Synchronization config here.

> **[Synchronization | Directus Docs](https://directus.io/docs/configuration/synchronization#redis)**
>
> Explore our resources and powerful data engine to build your projects confidently.

The `SYNCHRONIZATION_STORE` defaults to `memory` vs `redis` so you have to make sure you’re setting that explicitly.

---

<div class="post-metadata">

**Author:** ![Attacler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/attacler/32/99_2.png) [@Attacler](https://community.directus.com/u/Attacler)\
**Post date:** [May 21, 2025, 11:35am UTC](https://community.directus.com/t/self-hosting-pm2-variables-and-flows/361/3 "2025-05-21T11:35:58Z")

</div>

Do you have Redis enabled and configured correctly?

Directus will always try to execute a cron but they have made a cron locking mechanism that relies on Redis. This will prevent multiple cronjobs from executing at the same time.

---

<div class="post-metadata">

**Author:** ![samhallam](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@samhallam](https://community.directus.com/u/samhallam)\
**Post date:** [May 21, 2025, 2:57pm UTC](https://community.directus.com/t/self-hosting-pm2-variables-and-flows/361/5 "2025-05-21T14:57:50Z")

</div>

Thanks both! I had set cache: redis using just the default config but appears I have completely missed this part of setting Redis up. I will look into this guide and get that up and running

---

<div class="post-metadata">

**Author:** ![ahmad\_quvor](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/ahmad_quvor/32/310_2.png) [@ahmad\_quvor](https://community.directus.com/u/ahmad_quvor)\
**Post date:** [May 20, 2025, 7:27am UTC](https://community.directus.com/t/self-hosting-pm2-variables-and-flows/361/2 "2025-05-20T07:27:16Z")

</div>

We were facing the same problem as we were syncing products from **Shopify** , so we moved it away from the Directus to a different inhouse **NestJs** service

If you still want to use Directus then you will have to move it into custom hooks, and their use **Redis** based locking
