We scaled up our resources to have our server run 3 instances. Previously we had a script that would run when the app starts up - it worked okay for 1 instance but is now running 3 times (one on each service). Ideally we only run the script once after a deploy (it’s mostly idempotent but does have some interesting race conditions if run multiple times concurrently).
Couple things we were considering:
- Using a post deploy webhook where render tells us it is done deploying, then we run the script. Last I checked, this was not available yet
- Use some crude numbering system environment variable where we could denote that only a specific index or instance should run the script on startup. To do this, we would need an environment variable set per instance (we were thinking of a simple 0, 1, 2 index)
Are either of these possible? If not, do you have any other suggestions to handle the horizontal nature of multiple instances. We’re looking for a quick solution to this while we work on a more scalable solution that doesn’t involve running this script on app startup