Configuration

Service Definitions

Service definitions in runnem allow you to configure how each service in your project should be managed. This page details all the available configuration options for services.

Basic Service Definition

A minimal service definition requires only a command:

services:
  api:
    command: npm run dev

Full Service Definition

A complete service definition can include:

services:
  api:
    command: cd ~/projects/myproject/api && npm run dev
    url: http://localhost:3000
    depends_on: ["database"]
    env:
      NODE_ENV: development
      PORT: 3000

Configuration Options

Required Fields

  • command: The command to run the service
    api:
      command: npm run dev
    

Optional Fields

  • url: URL to check if the service is running

    api:
      url: http://localhost:3000
    
  • depends_on: List of services this service depends on

    frontend:
      depends_on: ["api"]
    
  • env: Environment variables for the service

    api:
      env:
        NODE_ENV: development
        PORT: 3000
    

Command Examples

Node.js Service

api:
  command: cd ~/projects/myproject/api && npm run dev
  url: http://localhost:3000

Python Service

worker:
  command: cd ~/projects/myproject/worker && python main.py
  env:
    PYTHONPATH: .

Docker Service

database:
  command: cd ~/projects/myproject/database && docker-compose up
  url: postgresql://localhost:5432

Multiple Commands

frontend:
  command: |
    cd ~/projects/myproject/frontend
    npm install
    npm run dev

Best Practices

  1. Use absolute paths in commands
  2. Define URLs for services when possible
  3. Keep commands simple and focused
  4. Use environment variables for configuration
  5. Group related commands using the pipe operator
  6. Document complex commands with comments
  7. Test commands before adding them to the configuration

Common Patterns

Development vs Production

api:
  command: |
    cd ~/projects/myproject/api
    if [ "$NODE_ENV" = "production" ]; then
      npm run start
    else
      npm run dev
    fi

Service with Dependencies

frontend:
  command: npm run dev
  url: http://localhost:3001
  depends_on: ["api", "database"]

Next Steps

  • Service Management - Learn how to manage your development services
  • CLI Reference - Browse through the list of options in Runnem's command-line interface
  • Why Runnem? - Learn the philosophy and motivation behind the tool
Previous
YAML Configuration