Skip to content

Commit 75eea22

Browse files
authored
docs: update README.md
1 parent 25104e7 commit 75eea22

1 file changed

Lines changed: 36 additions & 77 deletions

File tree

README.md

Lines changed: 36 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,68 @@
11
# http-pull
2-
3-
A lightweight Go service that periodically downloads files via HTTP(S), stores them locally, and runs configurable hooks afterward.
2+
Simple service that pulls files via http(s) in configurable intervals, stores them on your system and executes hooks after each successful and/or failed download. Configurable via YAML.
43

54
## Features
6-
7-
- **Scheduled HTTP pulls** — download files at configurable intervals per target
8-
- **Atomic writes** — files are written to a temp file first, then renamed into place
9-
- **Built-in hooks** — run shell commands or move files after each download
10-
- **Extensible hook interface** — third-party hooks via a public Go interface in `pkg/hook`
11-
- **Live reload** — send `SIGHUP` to re-read configuration without restarting
12-
- **Graceful shutdown** — in-flight downloads and hooks complete before exit
13-
- **Structured logging** — JSON logs via `slog`, configurable level and output target
5+
- **Easily Configurable** - Configure which files to pull in which interval and what to do with them in a single configuration file
6+
- **Sub-Minute Intervals** - Pull files as often (or as infrequent) as you need to
7+
- **Atomic Writes** - Files are downloaded into a temporary file, first, then atomically moved into place (`inotify`-compatible)
8+
- **Hooks** - Configure hooks to be executed after a pull was completed successfully or after it failed
9+
- **Extensible** - Easily develop own hooks by satisfying a simple Go interface with just one method
1410

1511
## Installation
12+
You can download a [pre-built binary](https://github.com/rescaled/http-pull/releases) for macOS, Linux or Windows from GitHub.
1613

17-
Requires Go 1.24+.
14+
Ubuntu or Debian users can also install `http-pull` as package.
15+
16+
## Build
17+
Building this project requires Go 1.24+ to be installed on your system.
1818

1919
```sh
20+
git clone git@github.com:rescaled/http-pull.git
21+
cd http-pull
2022
go build -o http-pull ./cmd/http-pull/
2123
```
2224

2325
## Usage
26+
Running the service is as easy as pointing to a configuration file. By default, `http-pull` assumes that the configuration file is stored at `/etc/http-pull/config.yaml`. It's recommended to run the software in the background or as service with e.g. systemd. You can find a [systemd service template](https://github.com/rescaled/http-pull/blob/main/packaging/systemd/http-pull.service) in the `packaging/` directory that is being used to build the .deb packages for Ubuntu and Debian and adapt it to your needs, if necessary.
2427

2528
```sh
2629
http-pull --config /path/to/config.yaml
2730
```
2831

29-
| Flag | Default | Description |
30-
|------|---------|-------------|
31-
| `--config` | `/etc/http-pull/config.yaml` | Path to the configuration file |
32-
33-
### Signals
34-
35-
| Signal | Behaviour |
36-
|--------|-----------|
37-
| `SIGHUP` | Reload configuration and apply changes live |
38-
| `SIGINT` / `SIGTERM` | Graceful shutdown (30s timeout for in-flight work) |
39-
4032
## Configuration
4133

4234
```yaml
4335
log:
44-
level: INFO # DEBUG, INFO, WARN, or ERROR
45-
target: stdout # stdout or file
46-
file: /var/log/http-pull.log # only used when target is "file"
36+
level: INFO # DEBUG, INFO, WARN, or ERROR
37+
target: stdout # stdout or file
38+
file: /var/log/http-pull.log # only used when target is "file"
4739

4840
targets:
49-
- name: example
50-
url: https://example.com/data.txt
51-
interval: 30s
52-
destination: /tmp/data.txt
53-
http_request: # optional
54-
method: GET # default: GET
55-
headers: # optional
41+
- name: example # unique target name
42+
url: https://example.com/data.txt # URL to download from
43+
interval: 30s # interval as Go-compatible expression
44+
destination: /tmp/data.txt # final destination for the downloaded file
45+
http_request: # optional
46+
method: GET # default: GET
47+
headers: # optional
5648
- name: Authorization
5749
value: Bearer my-token
58-
basic_auth: # optional
59-
username: user
60-
password: pass
61-
follow_redirects: true # default: true
62-
hooks: # optional
63-
- type: shell
50+
basic_auth: # optional
51+
username: username
52+
password: password
53+
follow_redirects: true # default: true
54+
hooks: # optional
55+
- type: shell # `shell` or `move`
6456
command: echo "Downloaded successfully"
65-
on: # default: [success]
57+
on: # default: [success]
6658
- success
6759
- failure
68-
- type: move
60+
- type: move
6961
destination: /opt/data/data.txt
7062
```
7163
72-
### Defaults
73-
74-
| Setting | Default |
75-
|---------|---------|
76-
| `log.level` | `INFO` |
77-
| `log.target` | `stdout` |
78-
| `http_request.method` | `GET` |
79-
| `http_request.follow_redirects` | `true` |
80-
| `hooks[].on` | `["success"]` |
81-
| `User-Agent` header | `http-pull/1.0` (overridable via `headers`) |
82-
8364
## Hooks
8465
85-
### Built-in hooks
86-
8766
**`shell`** — Executes a command via `/bin/sh -c` after the pull completes.
8867

8968
```yaml
@@ -100,16 +79,8 @@ targets:
10079
on: [success]
10180
```
10281

103-
### Hook triggers
104-
105-
| Value | Description |
106-
|-------|-------------|
107-
| `success` | Run when the download succeeds (HTTP status < 400) |
108-
| `failure` | Run when the download fails (HTTP status >= 400 or network error) |
109-
110-
### Writing custom hooks
111-
112-
The hook interface is in `pkg/hook` so it can be imported by external projects:
82+
## Custom Hooks
83+
The hook interface is in `pkg/hook` so it can be imported by external projects. Writing your own hook is as easy as satisfying the interface's single method.
11384

11485
```go
11586
import "http-pull/pkg/hook"
@@ -124,19 +95,7 @@ func (h *MyHook) Execute(ctx context.Context, result hook.Result) error {
12495
}
12596
```
12697

127-
## Project structure
128-
129-
```
130-
cmd/http-pull/ Entry point and signal handling
131-
internal/
132-
config/ Configuration loading and validation (Viper)
133-
logging/ Structured logging setup (slog)
134-
hook/ Built-in hook implementations and registry
135-
puller/ HTTP download with atomic file writes
136-
runner/ Worker orchestration, reload, and graceful shutdown
137-
pkg/hook/ Public hook interface for third-party extensions
138-
```
98+
We happily accept pull requests for new hooks to extend the possibilities `http-pull` offers its users.
13999

140100
## License
141-
142-
See [LICENSE](LICENSE) for details.
101+
MIT License

0 commit comments

Comments
 (0)