Installation

How to install and run Resgate

Install via Docker

If you install Docker, it is easy to run both NATS server and Resgate as containers:

docker network create res
docker run -d --name nats -p 4222:4222 --net res nats
docker run --name resgate -p 8080:8080 --net res resgateio/resgate --nats nats://nats:4222

Both images are small, less than 10 MB each.

Install release binary

Get the binary-zip file matching your architecture, either from the download page, or from the GitHub releases page.

Unzip the file. Inside the folder, there is a single command-line executable ready to run. That’s it!

Install from source

An alternative is to build the binaries yourself. First make sure you have:

Download and build Resgate using go get:

go get -u github.com/resgateio/resgate

Running Resgate

Before starting Resgate, NATS Server must be installed and running. Don’t worry; installing NATS is just as easy.

To run Resgate with default settings:

resgate

When started successfully, it will connect to NATS on TCP port 4222 and output something like:

2006/01/02 15:04:05 [Main] Starting server
2006/01/02 15:04:05 [NATS] Connecting to NATS at nats://127.0.0.1:4222
2006/01/02 15:04:05 [Main] Starting HTTP server
2006/01/02 15:04:05 [Main] Listening on http://0.0.0.0:8080

Tip

If you get the following error:

Failed to connect to messaging system: nats: no servers available for connection

Then you either don’t have NATS server running, or Resgate is configured to connect to the wrong port.

For more options, read about Resgate configuration and usage.

Try out Resgate with one of the examples.

Note

In production environments, Resgate should be restarted on failure.

Resgate is designed to exit with an error code if something goes wrong, and will recover once restarted. This can be done by using Restart=on-failure in the systemd service configuration on Linux, or using the Docker restart policy, --restart on-failure.