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 serviceapi: command: npm run dev
Optional Fields
url
: URL to check if the service is runningapi: url: http://localhost:3000
depends_on
: List of services this service depends onfrontend: depends_on: ["api"]
env
: Environment variables for the serviceapi: 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
- Use absolute paths in commands
- Define URLs for services when possible
- Keep commands simple and focused
- Use environment variables for configuration
- Group related commands using the pipe operator
- Document complex commands with comments
- 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