Skip to content

Latest commit

 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Replikator API

Go Report Card Build Status

This project adds a REST API around the Replikator that makes it possible to manage the replikated databases using a REST api.

Usage of replikator-api:
	Restfull Replikator API server
Options:
  -l, --listen=:8080                      listen address
  -r, --replikator="sudo replikator-ctl"  Path to replikator-ctl
  -s, --secret=                           CORS secret, minimal length 20 chars
  -h, --help                              Show usage message
  --version                               Show version

Run locally

Usage:

$ go get github.com/MarijnKoesen/replikator-api
$ go build github.com/MarijnKoesen/replikator-api
$ ./replikator-api

# when you don't have replikator-ctl available
$ ./replikator-api -r echo

From source:

$ git clone git@github.com:MarijnKoesen/replikator-api.git
$ go run . -r echo
> curl -XPUT localhost:8080/replikator/foo -vvv
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> PUT /replikator/foo HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json
< Date: Wed, 26 Oct 2022 11:22:50 GMT
< Content-Length: 27
<
--output json --create foo
* Connection #0 to host localhost left intact

Installation on server

Steps to install replikator-api on an ubuntu server:

  1. Install replikator-ctl in /usr/bin/replikator-ctl

  2. Create a replikator user/group

# groupadd replikator
# useradd -r -s /bin/nologin replikator2
  1. Create file /etc/sudoers.d/replikator with content:
replikator ALL=(ALL) NOPASSWD:/usr/bin/replikator-ctl
  1. Install replikator-api binary
# go get github.com/MarijnKoesen/replikator-api
# go build -o /usr/bin/replikator-api  github.com/MarijnKoesen/replikator-api
  1. Create a replikator service

Create file /etc/systemd/system/replikator-api.service

[Unit]
Description=Replikator API
ConditionPathExists=/usr/bin/replikator-api
After=network.target

[Service]
Type=simple
User=replikator
Group=replikator
LimitNOFILE=1024

KillMode=process

Restart=on-failure
RestartSec=10

ExecStart=/usr/bin/replikator-api

[Install]
WantedBy=multi-user.target

Now install and enable the service:

# systemctl daemon-reload
# systemctl enable replikator-api
# systemctl start replikator-api

About

This project adds a REST API around the Replikator that makes it possible to manage the replikated databases using a REST api.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages