README.md
April 10, 2022 · View on GitHub

A reverse proxy and load balancer for ambiorix applications (and shiny).
:warning: This implements a round robin, requests are redirected to whatever backend is next on the queue. This means you should not store any session-related data in the environment, use databases, cookies, parameters, etc. (as one should anyway). This will NOT work with shiny applications.
Install
go get github.com/devOpifex/belgic
or
go install github.com/devOpifex/belgic@latest
or download one of the available binaries.
Use
Belgic requires a very simple configuration file.
{
"path": "/belgic",
"port": "8080",
"backends": "max",
"attempts": 3
}
To create it you can use the config command and pass it the full
path to the directory where you want the configuration file
to be created.
./belgic config -p "path/to/directory"
path: the path containing the ambiorix application you want to serve. It assumes the application is in anapp.Rfile.port: port on which the apps should be served.backends: number of background applications to run in the background. Defaults to the maximum number of cores available on the machine.attempts: number of times to try and revive a backend if it dies.
Add the BELGIC_CONFIG environment variable to point to the configuration
file you just created.
Voilà, all set, just launch the server.
belgic start
# ./belgic start
Backends
The server will launch multiple applications in the background.
The number of applications running in the background is determined
by the backends variable defined in the configuration file.
Either set this option to the number of applications you want to
run in the background as a string,
e.g.: set it to "4" not 4.
If set to "max" if will run one application for each core
available on the machine.