Run services
A service runs as targets, the programs in its cmd/ directory. A server stays up, and a job such as migrations runs once. Its infrastructure is what it depends on, such as its database. Name a target <service>/<target>:
SERVICE=service-json-keys
TARGET=restFind what to run
a-novel run ps # every service and its state
a-novel run ps --service="$SERVICE" # one service and its state
a-novel run topology --service="$SERVICE" # what its targets depend onStart and stop a target
a-novel run start "$SERVICE/$TARGET"Dependencies start first: the database, then migrations, then the target. Targets run from source. Run the container image instead with --mode=container:
a-novel run start "$SERVICE/$TARGET" --mode=containera-novel run restart "$SERVICE/$TARGET"
a-novel run kill "$SERVICE/$TARGET"Infrastructure outlives its targets, so restarts are quick. Start it alone:
a-novel run service infra start "$SERVICE"Stop it once no target runs, or with --force:
a-novel run service infra kill "$SERVICE"Read the logs
a-novel run logs "$SERVICE/$TARGET" --follow # live, until Ctrl+C
a-novel run logs "$SERVICE/$TARGET" --tail=100 # the last 100 lines
a-novel run logs "$SERVICE/$TARGET" --previous # the run before thisCtrl+C stops following, not the target. Infrastructure logs stream the same way, by the ID run ps shows.
Reach a running service
Ports change on every run; ask the CLI:
eval "$(a-novel run env "$SERVICE")"
curl "$REST_URL/ping"run exec runs a command with a target's environment, inside its container when it has one. A command on your machine reaches the database through POSTGRES_DSN or the discrete POSTGRES_* settings:
a-novel run exec "$SERVICE/migrations" -- sh -c 'psql "$POSTGRES_DSN"'For a target running from source, get the debugger's attach command:
a-novel run debug "$SERVICE/$TARGET"Script it
run watch streams state changes as JSON, one object per line:
a-novel run watch --service="$SERVICE"run ps --json and run env --format=json cover the rest.