gofasta serve
Starts the project’s HTTP server by delegating to the project’s own binary — go run ./app/main serve. No file watching, no Air, no reload on change. This is the production-shaped way to run the server; for the development loop use gofasta dev.
Usage
gofasta serveRun it from the project root. gofasta serve defines no flags of its own, but because it shells out to the project binary, any flags the project’s own serve subcommand registers are forwarded through unchanged.
What it does
- Loads
.envfrom the project root into the environment. This matters: a scaffolded project keeps its database credentials,REDIS_URL, and similar in.env, and the library’s config loader reads from the process environment without loading.envitself. The CLI populates the environment before spawning so the child inherits everything it needs. - Spawns
go run ./app/main servewith stdin, stdout, and stderr wired straight through, so the server’s logs stream to your terminal andCtrl+Creaches the server.
Server configuration — host, port, environment, database, cache, queue — comes from config.yaml and its GOFASTA_-prefixed environment overrides, not from CLI flags. See the Configuration guide.
Endpoints
With the scaffold’s defaults (server.port: "8080"):
| Surface | Path | Notes |
|---|---|---|
| REST API | /api/v1/… | The prefix the index router mounts. |
| Health probes | /health, /health/live, /health/ready | Liveness and readiness, including dependency status. |
| Swagger UI | /swagger/index.html | Populated by gofasta swagger. |
| GraphQL | /graphql | Only in projects created with --graphql. |
| GraphQL playground | /graphql-playground | Same condition. |
| Prometheus metrics | /metrics | When observability.metrics_enabled is true. |
Run gofasta routes to see the actual registered REST surface for your project rather than the defaults.
Running it for real
go run compiles on every start, which is fine locally but wasteful for a long-lived deployment. In production, build once and run the binary:
go build -o server ./app/main
./server serveThe scaffold’s Dockerfile already does this — build the image and run it:
docker build -t myapp .
docker run -p 8080:8080 myappgofasta deploy wraps the whole path — build, ship over SSH, restart under systemd or Docker, and health-check the result before considering the release live.