Why Deploy?
Running a bot on your local machine requires:- Keeping your computer on 24/7
- Maintaining a stable internet connection
- Manual restarts after crashes or updates
- 24/7 uptime - Bot runs continuously in the cloud
- Auto-restart - Automatically restarts if it crashes
- Free tier - Railway offers $5 free credit for 30 days
- Simple deployment - One command to deploy
Railway Deployment
Railway is the recommended platform for running Turbine bots. It’s simple, affordable, and designed for Python applications.Prerequisites
- A working trading bot (see Building Bots)
- A Railway account (railway.app)
- Your bot’s private key and API credentials
Quick Deploy
The fastest way to deploy is using the Railway deployment script:- Check if Railway CLI is installed (installs it if needed)
- Create a new Railway project
- Set up environment variables
- Deploy your bot
- Provide you with the deployment URL
Railway offers **5-10/month depending on usage.
Manual Railway Setup
If you prefer to deploy manually:# macOS/Linux
curl -fsSL https://railway.app/install.sh | sh
# Or via npm
npm install -g @railway/cli
railway variables set TURBINE_PRIVATE_KEY="0xyour_private_key_here"
railway variables set TURBINE_API_KEY_ID="your_api_key_id"
railway variables set TURBINE_API_PRIVATE_KEY="your_api_private_key"
railway variables set CHAIN_ID="137"
railway variables set TURBINE_HOST="https://api.turbinefi.com"
Security: Never commit your
.env file or private keys to git. Railway stores environment variables securely.{
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python my_bot.py",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
requirements.txtProject Structure for Deployment
Your deployed bot should have this structure:requirements.txt
Create arequirements.txt file with your dependencies:
requirements.txt
.gitignore
Don’t commit sensitive files:.gitignore
Environment Variables on Railway
Railway manages environment variables through its dashboard or CLI.Required Variables
Optional Variables
Set via CLI
Set via Dashboard
- Go to railway.app
- Select your project
- Click “Variables” tab
- Add variables using the UI
Monitoring Your Bot
View Logs
Check Status
Restart Bot
Access Railway Dashboard
- View real-time logs
- Monitor resource usage (CPU, memory)
- Manage environment variables
- Configure auto-scaling
- Set up custom domains
Advanced Configuration
Auto-Restart on Failure
Configure automatic restarts inrailway.json:
Health Checks
Add a simple HTTP health check endpoint to your bot:railway.json:
Logging Configuration
Structured logging for production:Cost Optimization
Railway Pricing
Railway charges based on:- Execution time - How long your bot runs
- Memory usage - RAM consumed
- Network egress - Outbound data transfer
Reduce Costs
- Optimize polling intervals - Don’t poll faster than necessary
- Batch API calls - Reduce network requests
- Efficient logging - Don’t log every trivial event
- Clean up old data - Don’t accumulate logs in memory
Scaling
Horizontal Scaling
Run multiple bot instances:Resource Limits
Set memory limits inrailway.json:
Troubleshooting
Bot Keeps Crashing
Check logs for errors:- Missing environment variables
- Invalid API credentials
- Insufficient USDC balance
- Network timeouts
”Build Failed” Error
Ensurerequirements.txt is complete:
Environment Variables Not Loading
Verify variables are set:os.getenv(), not just .env file.
High Memory Usage
Optimize your bot:- Limit orderbook depth in memory
- Clear old trade data periodically
- Use generators instead of lists for large datasets
Alternative Platforms
While Railway is recommended, you can also deploy to:Render
Heroku
DigitalOcean App Platform
AWS / GCP / Azure
For advanced users, deploy to:- AWS Lambda (serverless)
- Google Cloud Run (containerized)
- Azure Container Instances
Next Steps
Build a Trading Bot
Create a bot to deploy
Monitor Performance
Track your bot’s performance
WebSocket Streams
Optimize with real-time data
Example Bots
Browse production-ready bots