Documentation

Before hooks and env files

Prepare a local environment before Vectron starts your long-running processes.

When to use this

Use this pattern when local services need preparation before the workspace starts: secrets, generated files, local images, database migrations, or shared environment values.

Example

[global]
log_mode = "both"
log_format = "json"
env_file = ".env"
before = [
  "./tools/prepare-local-secrets.sh",
  "./tools/ensure-dev-images.sh",
  "./tools/prebuild-services.sh",
]

[global.readiness]
type = "log"

[global.readiness.ready]
pattern = "service_ready"

[[process]]
name = "api-public"
command = "./tools/run_service.sh api-public"

[[process]]
name = "worker-jobs"
command = "./tools/run_service.sh worker-jobs"

Why this works

before commands run before Vectron starts the long-running process list. This keeps setup work out of individual service commands and makes startup failures easier to diagnose.

env_file = ".env" gives every process the same base environment. Process-level env and env_file entries can still add or override values later.

Defaults involved here

  • before: default none
  • env_file: default none
  • log_dir: default .vectron/logs
  • cleanup_logs: default true
  • process.readiness: inherits global.readiness

What to customize

  • Keep before commands idempotent so repeated starts are safe.
  • Prefer small setup scripts with clear failure messages.
  • Store shared local values in .env, but keep secrets out of version control.
  • Move process-specific environment into [process.env] or a process-level env_file.

See also