systemg

Search docs

/
Install

How It Works

Hooks

Run any shell command after a successful service start or unsuccessful service exit.

Events

HookWhen
onstartService reaches readiness or a one-shot completes successfully
onerrService exits unsuccessfully before or after readiness

Configuration

services:
  postgres:
    command: "postgres -D /var/lib/postgres"
    hooks:
      onstart:
        command: "echo 'Postgres started'"
        timeout: "10s"
      onerr:
        command: "/usr/local/bin/report-crash postgres"

Hooks inherit service environment variables.

Execution

  • Run via sh -c
  • Fire-and-forget (no retries)
  • Timeout kills with SIGKILL
  • Failures logged but don't affect service

Behavior

ScenarioHooks
Start and readiness successonstart
Successful one-shot completiononstart
Spawn or readiness failure while runningNone
Clean exitNone
Manual stopNone
Unsuccessful exit before or after readinessonerr
Successful automatic restartonstart

Tips

  • Keep commands short
  • Use env vars for secrets
  • Make repeated actions idempotent
CronState