mirror of
https://github.com/0x1d/rcond.git
synced 2025-12-15 18:48:19 +01:00
docs: update docs
This commit is contained in:
16
Makefile
16
Makefile
@@ -4,17 +4,26 @@ ADDR ?= 0.0.0.0:8080
|
|||||||
|
|
||||||
default: build
|
default: build
|
||||||
|
|
||||||
|
.PHONY: info
|
||||||
|
info:
|
||||||
|
@echo "Available targets:"
|
||||||
|
@grep '^##' Makefile | sed 's/^##//'
|
||||||
|
|
||||||
|
## generate: Generate Swagger Spec
|
||||||
generate:
|
generate:
|
||||||
swagger generate server -f api/rcond.yaml -t api/
|
swagger generate server -f api/rcond.yaml -t api/
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
|
## test: run tests
|
||||||
test:
|
test:
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
|
|
||||||
|
## build: build binary for target $ARCH
|
||||||
build:
|
build:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
env GOOS=linux GOARCH=${ARCH} go build -o bin/rcond-${ARCH} ./cmd/rcond/main.go
|
env GOOS=linux GOARCH=${ARCH} go build -o bin/rcond-${ARCH} ./cmd/rcond/main.go
|
||||||
|
|
||||||
|
## install: build and install binary for target $ARCH as systemd service
|
||||||
install: build
|
install: build
|
||||||
sudo mkdir -p /etc/rcond
|
sudo mkdir -p /etc/rcond
|
||||||
sudo mkdir -p /var/rcond
|
sudo mkdir -p /var/rcond
|
||||||
@@ -25,6 +34,7 @@ install: build
|
|||||||
sudo systemctl enable rcond
|
sudo systemctl enable rcond
|
||||||
sudo systemctl start rcond
|
sudo systemctl start rcond
|
||||||
|
|
||||||
|
## uninstall: uninstall systemd service
|
||||||
uninstall:
|
uninstall:
|
||||||
sudo systemctl stop rcond
|
sudo systemctl stop rcond
|
||||||
sudo systemctl disable rcond
|
sudo systemctl disable rcond
|
||||||
@@ -33,14 +43,18 @@ uninstall:
|
|||||||
sudo rm /usr/local/bin/rcond
|
sudo rm /usr/local/bin/rcond
|
||||||
sudo rm /etc/systemd/system/rcond.service
|
sudo rm /etc/systemd/system/rcond.service
|
||||||
|
|
||||||
|
## run: run and build binary for target $ARCH
|
||||||
run: build
|
run: build
|
||||||
bin/rcond-${ARCH} -config config/rcond.yaml
|
bin/rcond-${ARCH} -config config/rcond.yaml
|
||||||
|
|
||||||
|
## dev: run go programm
|
||||||
dev:
|
dev:
|
||||||
go run cmd/rcond/main.go -config config/rcond.yaml
|
go run cmd/rcond/main.go -config config/rcond.yaml
|
||||||
|
|
||||||
|
## dev-agent: run go programm with agent config
|
||||||
dev-agent:
|
dev-agent:
|
||||||
go run cmd/rcond/main.go -config config/rcond-agent.yaml
|
go run cmd/rcond/main.go -config config/rcond-agent.yaml
|
||||||
|
|
||||||
|
## upload: upload binary of given $ARCH to rpi-test
|
||||||
upload:
|
upload:
|
||||||
scp bin/rcond-${ARCH} pi@192.168.1.43:/home/pi/rcond
|
scp bin/rcond-${ARCH} pi@rpi-test:/home/pi/rcond
|
||||||
|
|||||||
44
README.md
44
README.md
@@ -26,26 +26,21 @@ export ARCH=arm64
|
|||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Run
|
## Development
|
||||||
|
|
||||||
The run target will build the binary for target architecture and runs it using the default configuration in `config/rcond.yaml`
|
There are several make targets available:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make run
|
Available targets:
|
||||||
```
|
generate: Generate Swagger Spec
|
||||||
|
test: run tests
|
||||||
## Develop
|
build: build binary for target $ARCH
|
||||||
|
install: build and install binary for target $ARCH as systemd service
|
||||||
The dev target will run the main.go using the default configuration in `config/rcond.yaml`
|
uninstall: uninstall systemd service
|
||||||
|
run: run and build binary for target $ARCH
|
||||||
```sh
|
dev: run go programm
|
||||||
make dev
|
dev-agent: run go programm with agent config
|
||||||
```
|
upload: upload binary of given $ARCH to rpi-test
|
||||||
|
|
||||||
You can also run a cluster agent in dev mode:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
make dev-agent
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
@@ -132,7 +127,6 @@ All endpoints except `/health` require authentication via an API token passed in
|
|||||||
| POST | `/cluster/leave` | Leave the cluster |
|
| POST | `/cluster/leave` | Leave the cluster |
|
||||||
| POST | `/cluster/event` | Send a cluster event |
|
| POST | `/cluster/event` | Send a cluster event |
|
||||||
|
|
||||||
|
|
||||||
### Response Codes
|
### Response Codes
|
||||||
|
|
||||||
- 200: Success
|
- 200: Success
|
||||||
@@ -148,12 +142,18 @@ All endpoints use JSON for request and response payloads.
|
|||||||
Cluster events are used for broadcast messages to all nodes in the cluster. They are sent as HTTP POST requests to the `/cluster/event` endpoint.
|
Cluster events are used for broadcast messages to all nodes in the cluster. They are sent as HTTP POST requests to the `/cluster/event` endpoint.
|
||||||
|
|
||||||
The request body should be a JSON object with the following fields:
|
The request body should be a JSON object with the following fields:
|
||||||
- `name`: The name of the event
|
|
||||||
- `payload`: The payload of the event, optional
|
| Field | Description | Optional |
|
||||||
|
|----------|-----------------------------------------|-----------|
|
||||||
|
| `name` | The name of the event | No |
|
||||||
|
| `payload`| The payload of the event | Yes |
|
||||||
|
|
||||||
The response will be a JSON object with the following fields:
|
The response will be a JSON object with the following fields:
|
||||||
- `status`: The status of the event. This is a string, either "success" or "error".
|
|
||||||
- `error`: If the status is "error", this field will contain a string describing the error. This field is optional.
|
| Field | Description | Optional |
|
||||||
|
|----------|----------------------------------------------------------------------------------|-----------|
|
||||||
|
| `status` | The status of the event. This is a string, either "success" or "error". | No |
|
||||||
|
| `error` | If the status is "error", this field will contain a string describing the error. | Yes |
|
||||||
|
|
||||||
Following events are implemented:
|
Following events are implemented:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user