24 days ago
Hi everyone,
I'm working on a project where I have two separate bots (Discord and Twitch) that need to run simultaneously. Both bots need to read from, update, and write to the same railway.json file, which acts as a shared data source.
The main challenge is ensuring that both bots can constantly check the file for updates without causing conflicts or data corruption. Additionally, both bots contain loops, which makes running them together more complex, as I want them to operate concurrently without blocking each other.
Could anyone advise on the best way to:
Run both bots concurrently, despite their internal loops
Enable both bots to constantly monitor and update railway.json safely
Implement synchronization so that updates from one bot are not overwritten or corrupted by the other
Any suggestions, best practices, or example implementations would be greatly appreciated!
Thanks in advance! i was hoping to avoid making a database because I had a hard time setting that up before - I am new to all of this and learning as I go
Pinned Solution
24 days ago
I would recommend using Redis or some sort of database to avoid IO errors.
Alternatively, you could implement mutexing in your service, which disallows the writing/reading of the file while the other bot is running IO operations on it, but it may get complicated/messy pretty quickly, but this would cause minor blocking (probably by a few ms though; r/w doesn't take that long).
1 Replies
24 days ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 24 days ago
24 days ago
I would recommend using Redis or some sort of database to avoid IO errors.
Alternatively, you could implement mutexing in your service, which disallows the writing/reading of the file while the other bot is running IO operations on it, but it may get complicated/messy pretty quickly, but this would cause minor blocking (probably by a few ms though; r/w doesn't take that long).
Status changed to Solved brody • 21 days ago