Deploying Multiple Python Bots to a Single Railway Container
A tutorial for running two or more python bots on Railway inside one container and one service, with independent crash recovery for each. Deploying Multiple Python Bots to a Single Railway Container If you're running more than one Python bot — say, a Telegram ingestion bot and a Discord notification bot that share a database — deploying each as its own Railway service means double the hosting…
Running multiple Python bots on Railway in the same container and single service can save on costs, simplify configuration, and maintain independent crash recovery. Instead of deploying each bot as its own Railway service, which would double hosting costs and configuration, this tutorial shows how to place both bots inside one Railway container.
The bots communicate through the main.py entry point, which uses the StayPresent library to supervise them individually. By installing StayPresent and structuring the project with a main.py script, each bot is run as a separate subprocess monitored independently. This setup allows both bots to share a database, queue, or other resources while still having separate crash recovery and monitoring.
Railway assigns a port to the service, which is read by StayPresent and passed to each bot's script, ensuring they each have their own port. Deploying the main.py script as the single Railway service runs both bots together, reducing hosting costs, while still providing separate monitoring and crash recovery for each bot.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.