Railway Deployment
Deploy RushChat backend service using Railway.
Railway Deployment Overview
Prerequisites
- Railway account (https://railway.app/)
- GitHub account
- Code pushed to GitHub
Deployment Steps
1. Create Railway Project
- Log in to Railway
- Click "New Project"
- Select "Deploy from GitHub repo"
- Select RushChat repository
- Select
server-rustdirectory as Root Directory
2. Add MySQL Database
- Click "New" on project page
- Select "Database" → "MySQL"
- Railway will automatically create database
- Record database connection information
3. Configure Environment Variables
Add environment variables in project settings:
DB_HOST=${{MySQL.MYSQLHOST}}
DB_PORT=${{MySQL.MYSQLPORT}}
DB_USER=${{MySQL.MYSQLUSER}}
DB_PASSWORD=${{MySQL.MYSQLPASSWORD}}
DB_NAME=${{MySQL.MYSQLDATABASE}}
PORT=5001
NODE_ENV=production
CLIENT_URL=https://your-frontend.vercel.app
MAIN_DOMAIN=your-domain.com
4. Configure Build Commands
Railway automatically detects Rust projects, but can be manually configured:
Build Command:
Start Command:
5. Run Database Migration
- On Railway project page
- Open MySQL database
- Use Railway CLI or MySQL client
- Run migration script:
6. Configure Persistent Storage
Railway uses temporary file system, need to configure Volume:
- Add Volume in project settings
- Mount to
/app/uploadsdirectory - Used for storing uploaded files
7. Configure Domain
- In project settings
- Click "Generate Domain"
- Or add custom domain
- Update frontend environment variables
Monitoring and Logs
View Logs
- On Railway project page
- Click "Deployments"
- Select latest deployment
- View real-time logs
Monitoring Metrics
Railway provides:
- CPU usage
- Memory usage
- Network traffic
- Request count
Troubleshooting
Build Failed
- Check Rust version
- Check if dependencies are correct
- View build logs
Runtime Errors
- Check environment variables
- Check database connection
- View application logs
Database Connection Failed
- Check if database service is running
- Check if environment variables are correct
- Check network connection