Skip to content

Railway

One-click Deploy Example

Deploy on Railway

Deploy an example project

https://github.com/joshstevens19/rindexer/tree/master/providers/railway

  1. Clone the relevant directory
# this will clone the railway directory
mkdir rindexer-railway && cd rindexer-railway
git clone \
  --depth=1 \
  --no-checkout \
  --filter=tree:0 \
  https://github.com/joshstevens19/rindexer .
git sparse-checkout set --no-cone providers/railway .
git checkout && cp -r providers/railway/* . && rm -rf providers
  1. Initialize a new Railway project

Install Railway CLI if not already installed.

railway login
railway init --name rindexer-example
  1. Create a service and link it to the project
railway up --detach
railway link
? Select a project
> rindexer-example
? Select an environment
> production
? Select a service
> rindexer-example
  1. Create a Postgres database
railway add --database postgres
  1. Configure environment variables
railway open
  • Open the service "Variables" tab:

  • Select "Add Variable Reference" and add a reference for DATABASE_URL and append ?sslmode=disable to the end of the value. The result should look like ${{Postgres.DATABASE_URL}}?sslmode=disable.

  • Select "Add Variable Reference" and add a reference for POSTGRES_PASSWORD.

  • Select "New Variable" with name PORT and value 3001 (This is the default value for the rindexer service, update this variable accordingly if the value is changed in the rindexer Dockerfile).

    • Hit "Deploy" or press Shift+Enter.
  1. Create a domain to access GraphQL Playground
railway domain
  1. Redeploy the service
railway up

Health Monitoring

Rindexer includes a built-in health monitoring server that provides comprehensive system status information. The health server runs on port 8080 by default and provides real-time insights into:

  • Database connectivity - PostgreSQL connection status
  • Indexing status - Whether the indexer is running and how many tasks are active
  • Sync status - Data synchronization health between different storage backends
  • Overall system health - Aggregated status across all components

Health Server Lifecycle

The health server's lifecycle depends on which services you start:

  • rindexer start indexer (with end_block set): Short-lived - dies when historical indexing completes
  • rindexer start indexer (no end_block set): Long-lived - stays alive for continuous live indexing
  • rindexer start graphql: No health server - health monitoring not available
  • rindexer start all: Long-lived - follows the GraphQL server lifecycle

Accessing Health Endpoints

The health server is automatically started when you run rindexer with indexing enabled. It provides the following endpoint:

  • GET /health - Complete health status with detailed service information

Example health response:

{
  "status": "healthy",
  "timestamp": "2024-01-15T10:30:00Z",
  "services": {
    "database": "healthy",
    "indexing": "healthy",
    "sync": "healthy"
  },
  "indexing": {
    "active_tasks": 2,
    "is_running": true
  }
}

Health Status Types

The health endpoint returns different status types:

  • healthy - Service is functioning normally
  • unhealthy - Service has encountered an error
  • unknown - Status cannot be determined
  • not_configured - Service is not set up
  • disabled - Service is intentionally disabled
  • no_data - Service is working but no data is available
  • stopped - Service is not running

Monitoring in Production

For production deployments on Railway, you can:

  1. Set up monitoring alerts based on HTTP status codes:
  • 200 OK - System is healthy
  • 503 Service Unavailable - System has issues
  1. Use Railway's built-in monitoring to track health metrics

  2. Set up automated alerts when the health status changes to unhealthy

  3. Access health endpoints through your Railway domain:

https://your-app.railway.app/health

Custom Health Port

You can configure the health server port in your rindexer.yaml file:

global:
  health_port: 8081