Gangpile
For when you need to run a script, repeatedly, and at scale.
What It Does
It spawns multiple subprocesses that run a script or a program repeatedly, ideally without arguments. These subprocesses cache the standard outputs (stdout and stderr), and stream them back to the gangpile manager. The manager will then put these logs into a SQLite database for you to examine later.
At first blush, this may seem to be DDoS tool, and it can certainly be used as one, but it’s not actually meant for that. It’s for load testing, annoying your S/O, and as an exercise to better understand Go’s concurrency and parallelism options.
Build It
go get
- Build the bits; order doesn’t matter:
go build -o bin/gangpile gangpile/gangpile.go
go build -o bin/localrunner localrunner/localrunner.go
- Bonus zsh powerword:
for p ('gangpile' 'localrunner') go build -o bin/$p $p/$p.go
- Bonus zsh powerword:
- Get together the script you want to abuse
Run It
- Get together an idempotent script like this one:
#!/bin/bash # -- naggem.sh -- # girlfriend is late again! this'll get her attention curl -XPUT -d'{"text": "ready yet?", "number": "+1888555MYGF"}' https://my.sms.api.fail/send-message
- Make the script executable
$ chmod +x naggem.sh
- Start the program from this directory
$ ./bin/gangpile local 12 path/to/naggem.sh
- Trivia:
- this will spawn 12 executors that will repeatedly hammer
naggem.sh
until the gangpile process is killed. - for best performance, ensure that you have at least 12 sufficiently bored CPUs on the computer you are running this on.
- gangpile will create a “run_logs.db” file. This is SQLite file you can use to examine logs and generate reports.
- both Python and Racket have SQLite support in their standard library, which means you can use the former to generate attractive graphs and with Jupyter.
- SQLite ships with most Linux distros, MacOSX, and Android!
- Yes, you can run this on your Android phone.
- It’ll gleely add to whatever “run_logs.db” you already have stored here.
- Twilio didn’t like my initial tests, and neither did my (now ex-) girlfriend.
- this will spawn 12 executors that will repeatedly hammer
- Trivia:
- ???
- Profit! (or breakup)
- Press
Ctrl-C
to end the gangpile