Skip to content

Commit

Permalink
Merge branch 'release/v0.2.0-alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaskoch committed Feb 16, 2017
2 parents 457d289 + a666d35 commit 7f4882e
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 31 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [v0.2.0-alpha] - 2017-02-07

### Fixed
- Shut down the UI 10 seconds after the crawler finished

### Changed
- Remove the TERABYTE constant from the byte formatter so cross-compilation for ARM works
- Remove the `reset` command hint from the troubleshooting section of the README
- Start the timer only after the links in the XML sitemap(s) have been read
- Stop counting the seconds after the crawler finished

### Removed
- Remove the debug console from the command-line ui

## [v0.1.0-alpha] - 2017-02-07

The Prototype
Expand Down
50 changes: 39 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

The fast website crawler

You can use「 gargantua 」to quickly and easily

- **warm-up** your frontend caches
- perform small **load-tests** against your publicly available pages
- **measure** response times
- **detect** broken links

from your command line on Linux, macOS and Windows.

![Animation: gargantua v0.1.0 crawling a website](files/gargantua-in-action-crawling-a-website.gif)

> Note: Press `Q` to stop the current crawling process.
## Usage

Crawl **www.sitemaps.org** with 5 concurrent workers:
Expand All @@ -10,25 +23,40 @@ Crawl **www.sitemaps.org** with 5 concurrent workers:
gargantua crawl --url https://www.sitemaps.org/sitemap.xml --workers 5
```

## Roadmap
see also: [A short introduction video of gargantua on YouTube](https://www.youtube.com/watch?v=TSCMvUvc0qo)

- Increase the number of workers at runtime
- Personalized user agent string
- Silent mode (only show statistics at the end)
- CSV mode (print CSV output to stdout)
- Dockerfile
- Web-UI
## Download

You can download binaries for Linux, macOS and Windows from [github.com »andreaskoch » gargantua » releases](https://github.com/andreaskoch/gargantua/releases):

## Troubleshooting
```bash
wget https://github.com/andreaskoch/gargantua/releases/download/v0.2.0-alpha/gargantua_linux_amd64
```

## Docker Image

### My console is messed up after gargantua exits
There is also a docker image that you can use to download or run the latest version of gargantua:

This has to do with gargantua's usage of ncurses. You can use the `reset` command to fix your command line window.
[andreaskoch/gargantua](https://hub.docker.com/r/andreaskoch/gargantua/)

```bash
reset
docker run --rm andreaskoch/gargantua:latest \
crawl \
--verbose \
--url https://www.sitemaps.org/sitemap.xml \
--workers 5
```

**Note**: You will need the `--verbose` flag in order to prevent the command-line UI from loading. Otherwise gargantua will fail.

## Roadmap

- Increase the number of workers at runtime
- Personalized user agent string
- Silent mode (only show statistics at the end)
- CSV mode (print CSV output to stdout)
- Web-UI

## License

「 gargantua 」is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full license text.
39 changes: 25 additions & 14 deletions dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/gizak/termui"
)

func dashboard(startTime time.Time, stopTheCrawler chan bool) {
func dashboard(stopTheUI, stopTheCrawler chan bool) {
if err := termui.Init(); err != nil {
panic(err)
}
Expand Down Expand Up @@ -69,16 +69,23 @@ func dashboard(startTime time.Time, stopTheCrawler chan bool) {
elapsedTime.BorderLabel = "Elapsed time"
elapsedTime.BorderFg = termui.ColorCyan

debugMessages := termui.NewList()
debugMessages.ItemFgColor = termui.ColorWhite
debugMessages.BorderLabel = "Debug"
debugMessages.Height = 6
debugMessages.Y = 0

draw := func() {

snapshot := stats.LastSnapshot()

// ignore empty updates
if snapshot.Timestamp().IsZero() {
return
}

// don't update if there is no new snapshot available
if len(snapshots) > 0 {
previousSnapShot := snapshots[len(snapshots)-1]
if snapshot.Timestamp() == previousSnapShot.Timestamp() {
return
}
}

// capture the latest snapshot
snapshots = append(snapshots, snapshot)

Expand Down Expand Up @@ -106,11 +113,8 @@ func dashboard(startTime time.Time, stopTheCrawler chan bool) {
// number of errors
numberOfErrors.Text = fmt.Sprintf("%d", snapshot.NumberOfErrors())

// debug messages
debugMessages.Items = errorMessages

// time since first snapshot
timeSinceStart := time.Now().Sub(startTime)
timeSinceStart := time.Now().Sub(snapshots[0].Timestamp())
elapsedTime.Text = fmt.Sprintf("%s", timeSinceStart)

termui.Render(termui.Body)
Expand All @@ -132,9 +136,6 @@ func dashboard(startTime time.Time, stopTheCrawler chan bool) {
termui.NewCol(3, 0, averageSizeInBytes),
termui.NewCol(3, 0, elapsedTime),
),
termui.NewRow(
termui.NewCol(12, 0, debugMessages),
),
)

termui.Body.Align()
Expand All @@ -158,5 +159,15 @@ func dashboard(startTime time.Time, stopTheCrawler chan bool) {
draw()
})

// stop when the crawler is done
go func() {
select {
case <-stopTheUI:
// wait 10 seconds before closing the ui
time.Sleep(time.Second * 10)
termui.StopLoop()
}
}()

termui.Loop()
}
Binary file added files/01-gargantua-help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added files/02-gargantua-crawl-command.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added files/03-gargantua-interface-and-statistics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added files/gargantua-in-action-crawling-a-website.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

const applicationName = "gargantua"
const applicationVersion = "v0.1.0-alpha"
const applicationVersion = "v0.2.0-alpha"

var (
app = kingpin.New(applicationName, fmt.Sprintf(`「 %s 」%s crawls all URLs of your website - starting with the links in your sitemap.xml
Expand Down Expand Up @@ -62,6 +62,7 @@ func handleCommandlineArgument(arguments []string) {

func startCrawling(targetURL url.URL, concurrentRequests, timeoutInSeconds int, debugModeIsEnabled bool) error {
stopTheCrawler := make(chan bool)
stopTheUI := make(chan bool)
crawlResult := make(chan error)

go func() {
Expand All @@ -70,6 +71,7 @@ func startCrawling(targetURL url.URL, concurrentRequests, timeoutInSeconds int,
Timeout: time.Second * time.Duration(timeoutInSeconds),
}, stopTheCrawler)

stopTheUI <- true
crawlResult <- result
}()

Expand All @@ -81,7 +83,7 @@ func startCrawling(targetURL url.URL, concurrentRequests, timeoutInSeconds int,

uiWaitGroup.Add(1)
go func() {
dashboard(time.Now(), stopTheCrawler)
dashboard(stopTheUI, stopTheCrawler)
uiWaitGroup.Done()
}()
}
Expand Down
4 changes: 0 additions & 4 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ const (
KILOBYTE = 1024 * BYTE
MEGABYTE = 1024 * KILOBYTE
GIGABYTE = 1024 * MEGABYTE
TERABYTE = 1024 * GIGABYTE
)

func formatBytes(numberOfBytes int) string {
unit := ""
value := float32(numberOfBytes)

switch {
case numberOfBytes >= TERABYTE:
unit = "T"
value = value / TERABYTE
case numberOfBytes >= GIGABYTE:
unit = "G"
value = value / GIGABYTE
Expand Down

0 comments on commit 7f4882e

Please sign in to comment.