Deploy to Railway
Always-on execution with auto-scaling and a free tier
One-Click Deploy
Deploy the TPMJS executor to Railway with a single click:
After deployment, your executor will be available at https://your-project.up.railway.app
Deploy via CLI
Prefer the command line? Deploy with the Railway CLI:
# Clone the template
git clone https://github.com/tpmjs/tpmjs.git
cd tpmjs/templates/railway-executor
# Install Railway CLI
npm install -g @railway/cli
# Login to Railway
railway login
# Create a new project and deploy
railway init
railway upTest Your Deployment
Verify your executor is running:
curl https://your-executor.up.railway.app/healthExpected response:
{
"status": "ok",
"version": "1.0.0",
"info": {
"runtime": "railway",
"timestamp": "2024-01-01T00:00:00.000Z",
"region": "us-west1"
}
}Add Authentication
Important: Without an API key, anyone can execute tools on your executor. Always set EXECUTOR_API_KEY in production.
- 1Go to your Railway project dashboard
- 2Click on your service, then go to "Variables"
- 3Add
EXECUTOR_API_KEYwith a secure random value - 4Railway will automatically redeploy with the new variable
Environment Variables
Add environment variables via the Railway dashboard or CLI:
# Set environment variables via CLI
railway variables set EXECUTOR_API_KEY=your-secure-key
railway variables set OPENAI_API_KEY=sk-xxx
railway variables set DATABASE_URL=postgres://...These variables will be available during tool execution.
Execute a Tool
Test tool execution with a curl request:
curl -X POST https://your-executor.up.railway.app/execute-tool \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key" \
-d '{
"packageName": "@tpmjs/hello",
"name": "helloWorldTool",
"version": "latest",
"params": { "includeTimestamp": true }
}'Local Development
Run the executor locally for testing:
# Clone the repository
git clone https://github.com/tpmjs/tpmjs.git
cd tpmjs/templates/railway-executor
# Run locally
PORT=3000 node index.js
# Test health endpoint
curl http://localhost:3000/healthDocker Deployment
The template includes a Dockerfile for container deployments:
# Build the image
docker build -t tpmjs-executor .
# Run locally
docker run -p 3000:3000 -e EXECUTOR_API_KEY=your-key tpmjs-executorRailway will automatically detect and use the Dockerfile if present.
How It Works
The Railway executor runs as an always-on Node.js service:
- 1Receives tool execution request via HTTP POST to
/execute-tool - 2Creates an isolated temporary directory for the execution
- 3Installs the npm package using
npm install - 4Loads the tool and calls its
execute()function - 5Returns the result and cleans up the temporary directory
Security
- Set
EXECUTOR_API_KEYto require authentication - Each tool execution uses an isolated temporary directory
- Environment variables stored encrypted by Railway
- All traffic encrypted via HTTPS
- Auto-restart on failure for high availability
Pricing
Railway offers usage-based pricing with a generous free tier:
| Tier | Price | Includes |
|---|---|---|
| Free Tier | $0/month | $5 credit, enough for light usage |
| Usage-based | ~$0.000463/min | 0.5 vCPU, 512MB RAM |
See Railway Pricing for current rates.
Connect to TPMJS
- 1. Go to your collection or agent settings on TPMJS
- 2. Select "Custom Executor" in Executor Configuration
- 3. Enter URL:
https://your-project.up.railway.app - 4. Enter your API key (if configured)
- 5. Click "Verify Connection"