Deploy to Railway

Always-on execution with auto-scaling and a free tier

$5
Free monthly credit
0ms
No cold starts
Auto
Scaling built-in

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 up

Test Your Deployment

Verify your executor is running:

curl https://your-executor.up.railway.app/health

Expected 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.

  1. 1Go to your Railway project dashboard
  2. 2Click on your service, then go to "Variables"
  3. 3Add EXECUTOR_API_KEY with a secure random value
  4. 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/health

Docker 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-executor

Railway will automatically detect and use the Dockerfile if present.

How It Works

The Railway executor runs as an always-on Node.js service:

  1. 1Receives tool execution request via HTTP POST to /execute-tool
  2. 2Creates an isolated temporary directory for the execution
  3. 3Installs the npm package using npm install
  4. 4Loads the tool and calls its execute() function
  5. 5Returns the result and cleans up the temporary directory

Security

  • Set EXECUTOR_API_KEY to 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:

TierPriceIncludes
Free Tier$0/month$5 credit, enough for light usage
Usage-based~$0.000463/min0.5 vCPU, 512MB RAM

See Railway Pricing for current rates.

Connect to TPMJS

  1. 1. Go to your collection or agent settings on TPMJS
  2. 2. Select "Custom Executor" in Executor Configuration
  3. 3. Enter URL: https://your-project.up.railway.app
  4. 4. Enter your API key (if configured)
  5. 5. Click "Verify Connection"