From 773b373dd59ca44df4c25bfced17c06d887e0773 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Sun, 19 Aug 2018 16:02:34 -0700
Subject: [PATCH] Readme

---
 README.md   | 37 ++++++++++++++++++++++++++++++++++++-
 glrdomon.go |  5 ++---
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 37af5bc..88e7f3b 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,38 @@
 # GitLab Runner Droplet Monitor [![pipeline status](https://git.ethitter.com/debian/gitlab-runner-do-monitor/badges/master/pipeline.svg)](https://git.ethitter.com/debian/gitlab-runner-do-monitor/commits/master)
 
-Monitor Digital Ocean for stale droplets created by GitLab Runner
\ No newline at end of file
+Monitor Digital Ocean for stale droplets created by GitLab Runner
+
+## Configuration
+
+```json
+{
+  "log-dest": "os.Stdout",
+  "api-key": "",
+  "threshold": 5400,
+  "delete-stale": true
+}
+
+```
+
+* `log-dest`: set to a path to write to a log file, otherwise `os.Stdout`
+* `api-key`: Digital Ocean Personal Access Token
+* `threshold`: time, in seconds, after which to consider a runner stale
+* `delete-stale`: whether to delete stale runners, in addition to reporting them
+
+##### A note about `threshold`
+
+This value needs to be greater than the job timeout specified in your GitLab Runner configuration, otherwise a runner may erroneously be considered stale.
+
+## Installation
+
+1. Download the appropriate binary from [tagged releases](https://git.ethitter.com/debian/gitlab-runner-do-monitor/tags), or build the binary yourself.
+1. Copy `config-sample.json` to an appropriate location and update the default values as needed.
+1. Create a cron task to periodically run the monitor.
+
+## Usage
+
+```bash
+./glrdomon -config config.json
+```
+
+* `-config`: specify path to config file, otherwise assumes `./config.json` relative to the binary
diff --git a/glrdomon.go b/glrdomon.go
index 5348a46..173a2cd 100644
--- a/glrdomon.go
+++ b/glrdomon.go
@@ -33,8 +33,7 @@ var (
 	logger  *log.Logger
 	logDest string
 
-	apiKey string
-
+	apiKey      string
 	threshold   int
 	deleteStale bool
 
@@ -62,11 +61,11 @@ func init() {
 		usage()
 	}
 
-	logDest = cfg.LogDest
 	apiKey = cfg.APIKey
 	threshold = cfg.Threshold
 	deleteStale = cfg.DeleteStale
 
+	logDest = cfg.LogDest
 	setUpLogger()
 
 	logger.Printf("Starting GitLab Runner monitoring with config %s", configPath)
-- 
GitLab