Bump to 0.1.0.

Update README.
This commit is contained in:
n0vad3v 2020-03-05 20:55:49 +08:00
parent d5f7977d97
commit 63a213e43d
No known key found for this signature in database
GPG Key ID: 8D42A0E699E50639
2 changed files with 21 additions and 14 deletions

View File

@ -34,19 +34,20 @@ It's basically between `ExpressJS` and `Fiber`, much faster than the `http` pack
This tool will check for new release whenever you run it. The updated binary will be save to `update` dir. This tool will check for new release whenever you run it. The updated binary will be save to `update` dir.
## General Usage Steps ## General Usage Steps
Regarding the `IMG_PATH` section in `config.json`.
If you are serving images at `https://example.com/pics/tsuki.jpg` and
your files are at `/var/www/image/pics/tsuki.jpg`, then `IMG_PATH` shall be `/var/www/image`.
`EXHAUST_PATH` is cache folder for output `webp` images, with `EXHAUST_PATH` set to `/var/cache/webp`
in the example above, your `webp` image will be saved at `/var/cache/webp/pics/tsuki.jpg.1582558990.webp`.
## 1. Download or build the binary ## 1. Download or build the binary
Download the `webp-server` from [release](https://github.com/n0vad3v/webp_server_go/releases) page. Download the `webp-server` from [release](https://github.com/n0vad3v/webp_server_go/releases) page.
Wanna build your own binary? Check out [build](#build-your-own-binaries) section Wanna build your own binary? Check out [build](#build-your-own-binaries) section
## 2. config file ## 2. Dump config file
Create a `config.json` as follows to face your need, default convert quality is 80%.
```
./webp-server -dump-config > config.json
```
The default `config.json` may look like this.
```json ```json
{ {
"HOST": "127.0.0.1", "HOST": "127.0.0.1",
@ -57,6 +58,13 @@ Create a `config.json` as follows to face your need, default convert quality is
"ALLOWED_TYPES": ["jpg","png","jpeg"] "ALLOWED_TYPES": ["jpg","png","jpeg"]
} }
``` ```
Regarding the `IMG_PATH` section in `config.json`.
If you are serving images at `https://example.com/pics/tsuki.jpg` and your files are at `/var/www/image/pics/tsuki.jpg`, then `IMG_PATH` shall be `/var/www/image`.
`EXHAUST_PATH` is cache folder for output `webp` images, with `EXHAUST_PATH` set to `/var/cache/webp`
in the example above, your `webp` image will be saved at `/var/cache/webp/pics/tsuki.jpg.1582558990.webp`.
## 3. Run ## 3. Run
``` ```
@ -88,11 +96,7 @@ By default, it will utilize all your CPU cores.
# use 4 cores # use 4 cores
./webp-server -prefetch -jobs=4 ./webp-server -prefetch -jobs=4
``` ```
### dump config.json
The standard `config.json` will show on your screen. You many want to use `>` to redirect to a file.
```
./webp-server -dump-config > config.json
```
### dump systemd service file ### dump systemd service file
The standard systemd service file will show on your screen. You many want to use `>` to redirect to a file. The standard systemd service file will show on your screen. You many want to use `>` to redirect to a file.
@ -107,6 +111,7 @@ screen -S webp
./webp-server --config /path/to/config.json ./webp-server --config /path/to/config.json
``` ```
(Use Ctrl-A-D to detach the `screen` with `webp-server` running.) (Use Ctrl-A-D to detach the `screen` with `webp-server` running.)
### systemd ### systemd
Don't worry, we've got you covered! Don't worry, we've got you covered!
@ -127,6 +132,7 @@ location ^~ /wp-content/uploads/ {
} }
``` ```
If you use Caddy, you may refer to [优雅的让 Halo 支持 webp 图片输出](https://halo.run/archives/halo-and-webp). If you use Caddy, you may refer to [优雅的让 Halo 支持 webp 图片输出](https://halo.run/archives/halo-and-webp).
## Advanced usage ## Advanced usage
## Build your own binaries ## Build your own binaries

View File

@ -4,11 +4,12 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"github.com/gofiber/fiber"
"log" "log"
"os" "os"
"path" "path"
"runtime" "runtime"
"github.com/gofiber/fiber"
) )
type Config struct { type Config struct {
@ -20,7 +21,7 @@ type Config struct {
ExhaustPath string `json:"EXHAUST_PATH"` ExhaustPath string `json:"EXHAUST_PATH"`
} }
const version = "0.0.4" const version = "0.1.0"
var configPath string var configPath string
var prefetch bool var prefetch bool