Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,19 @@ curl -X GET http://localhost:8000/v1/delivery-attempts/01E8HX1D6PYFB1HJFG0S7WEKB
```
docker build -f Dockerfile -t hammer .
```

## Disable REST API

To disable the rest api, set the environment variable **HAMMER_REST_API_ENABLED** to false.

```bash
export HAMMER_REST_API_ENABLED='false'
```

## Disable Prometheus metrics

To disable prometheus metrics, set the environment variable **HAMMER_METRICS_ENABLED** to false.

```bash
export HAMMER_METRICS_ENABLED='false'
```
8 changes: 8 additions & 0 deletions cmd/hammer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func newAppContext() appContext {
}

func gatewayServer() {
gatewayEnabled := env.GetBool("HAMMER_REST_API_ENABLED", true)
if !gatewayEnabled {
return
}
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
Expand All @@ -94,6 +98,10 @@ func gatewayServer() {
}

func metricsServer() {
metricsEnabled := env.GetBool("HAMMER_METRICS_ENABLED", true)
if !metricsEnabled {
return
}
port := env.GetInt("HAMMER_METRICS_PORT", 4001)
http.Handle("/metrics", promhttp.Handler())
err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
Expand Down
2 changes: 2 additions & 0 deletions local.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ HAMMER_WORKER_DATABASE_DELAY='5'
HAMMER_WORKER_DEFAULT_FETCH_LIMIT='100'
# See https://github.com/golang-migrate/migrate/tree/master/source/file
HAMMER_DATABASE_MIGRATION_DIR='file:///db/migrations'
HAMMER_REST_API_ENABLED='true'
HAMMER_METRICS_ENABLED='true'