Devbox Services: Tame Your Daemons with process-compose
Ever wished you could manage your development services as easily as with Docker Compose, but without all the Docker baggage? Say hello to Devbox Services, powered by process-compose.
What’s process-compose?
Think of process-compose as Docker Compose’s leaner, meaner cousin. It’s a dead-simple way to orchestrate your non-containerized apps. No more wrestling with Dockerfiles, volumes, or registries. Just define your services, and you’re off to the races.
Here’s what a process-compose.yml
might look like:
version: "0.5"
processes:
postgresql:
command: |
if ! grep -q "shared_preload_libraries = 'timescaledb'" $PGDATA/postgresql.conf; then
echo "shared_preload_libraries = 'timescaledb'" >> $PGDATA/postgresql.conf
fi
pg_ctl start -o "-k $PGHOST"
is_daemon: true
shutdown:
command: "pg_ctl stop -m fast"
availability:
restart: "always"
readiness_probe:
exec:
command: "pg_isready"
telegram-bot:
command: |
cd telegram-bot
make install
make dev
availability:
restart: "always"
depends_on:
postgresql:
condition: process_healthy
readiness_probe:
http_get:
host: 127.0.0.1
scheme: http
path: "/healthz"
port: 5001
initial_delay_seconds: 5
period_seconds: 10
timeout_seconds: 5
success_threshold: 1
failure_threshold: 3
Breaking It Down
Let’s dissect this beast:
PostgreSQL Process
postgresql:
command: |
if ! grep -q "shared_preload_libraries = 'timescaledb'" $PGDATA/postgresql.conf; then
echo "shared_preload_libraries = 'timescaledb'" >> $PGDATA/postgresql.conf
fi
pg_ctl start -o "-k $PGHOST"
is_daemon: true
shutdown:
command: "pg_ctl stop -m fast"
availability:
restart: "always"
readiness_probe:
exec:
command: "pg_isready"
This little chunk of YAML is doing some heavy lifting:
- It checks if TimescaleDB is enabled. If not, it adds it to the config.
- Fires up PostgreSQL with a custom socket directory.
- Tells process-compose this is a long-running daemon.
- Defines how to gracefully shut down PostgreSQL.
- Sets it to always restart if it crashes.
- Uses
pg_isready
to check if PostgreSQL is good to go.
Telegram Bot Process
telegram-bot:
command: |
cd telegram-bot
make install
make dev
availability:
restart: "always"
depends_on:
postgresql:
condition: process_healthy
readiness_probe:
http_get:
host: 127.0.0.1
scheme: http
path: "/healthz"
port: 5001
initial_delay_seconds: 5
period_seconds: 10
timeout_seconds: 5
success_threshold: 1
failure_threshold: 3
Here’s where it gets interesting:
- We’re setting up a Telegram bot with a simple
make install && make dev
. - It’ll restart if it crashes.
- It won’t start until PostgreSQL is healthy. No more race conditions!
- We’ve got a fancy HTTP health check to make sure the bot is actually working.
Devbox Services: Your New Best Friend
Now, here’s the kicker: Devbox wraps all this process-compose goodness into a simple CLI. No need to fumble with process-compose directly. Just use these magic commands:
devbox services ls
- See what’s cookingdevbox services restart
- Give your services a kickdevbox services start
- Fire everything updevbox services stop
- Shut it all down
It’s that easy. No containers, no fuss, just your services running smoothly in your Devbox environment.
The Bottom Line
Devbox Services with process-compose gives you the power of containerized workflows without the overhead. It’s perfect for development environments where you want simplicity and speed.