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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ _testmain.go

*.exe
*.test

# macOS
.DS_Store
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@ Cross-compile, e.g. for Linux:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o hammer.linux .
```

### Updating

Once installed, hammer can update itself in place:

```shell
hammer update # download the latest release and replace this binary
hammer update -check # only report whether a newer version is available
hammer update -version v1.2.0 # install a specific release
hammer update -y # skip the confirmation prompt (for scripts/CI)
```

`update` resolves the target release from the GitHub API, downloads the archive
for your platform, verifies it against `SHA256SUMS`, and atomically swaps the
running binary. It honors the same mirror controls as the installer — pass
`-mirror ghproxy` (or set `HAMMER_INSTALL_MIRROR`) when GitHub is unreachable,
and `HAMMER_REPO` to update from a fork. If the binary lives in a directory you
can't write to (e.g. `/usr/local/bin`), re-run with `sudo`.

## Quick start

Zero-config — hammer a single URL for 10 seconds at 50 rps (no profile file needed):
Expand Down
8 changes: 7 additions & 1 deletion hammer.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ Usage:
hammer -url URL [options] # zero-config: hammer a single URL
hammer -profile FILE [options] # weighted traffic mix from a file
hammer -profile - [options] # read the profile from stdin
hammer update [options] # self-update to the latest release

Agent-friendly options:
-output json emit the structured report to stdout (logs stay on stderr)
Expand All @@ -768,7 +769,12 @@ Options:
flag.PrintDefaults()
}

func main() { os.Exit(run()) }
func main() {
if len(os.Args) > 1 && os.Args[1] == "update" {
os.Exit(runUpdate(os.Args[2:]))
}
os.Exit(run())
}

func run() int {
var (
Expand Down
Loading