1
0
mirror of https://github.com/taigrr/nats.docs synced 2025-01-18 04:03:23 -08:00

wip server docs

This commit is contained in:
Alberto Ricart
2019-05-13 10:13:41 -05:00
parent 6c56793a22
commit 908d73835a
37 changed files with 4157 additions and 0 deletions

11
nats_server/README.md Normal file
View File

@@ -0,0 +1,11 @@
# NATS Server
The NATS server is an extremely lightweight, high-performance messaging server written in Go. Emphasys is on _simplicity_.
- [Installation](installation.md)

39
nats_server/clients.md Normal file
View File

@@ -0,0 +1,39 @@
## NATS Clients
The nats-server doesn't come bundled with any clients. But most client libraries come with tools that allow you to publish, subscribe, send requests and reply messages.
If you have a client library installed you can try using a bundled client. Otherwise you can easily install some clients.
### If you have Go installed:
```
> go get https://github.com/nats-io/go-nats-examples/tools/nats-pub
> go get https://github.com/nats-io/go-nats-examples/tools/nats-sub
```
### Or download a zip file
You can pre-built binaries from the [go-nats-examples repo](https://github.com/nats-io/go-nats-examples/releases/tag/0.0.50)
### Testing your setup
First [start a nats-server](running.md). Then you can on two different terminal windows:
Start a subscriber:
```
> nats-sub ">"
Listening on [>]
```
Publish your first message:
```
> nats-pub hello world
Published [hello] : 'world'
```
On the subscriber window you should see:
```
[#1] Received on [hello]: 'world'
```

View File

@@ -0,0 +1,64 @@
## NATS Server Installation
NATS philosophy is simplicity. Installation is just decompression a zip file and copying the binary to an appropiate directory; you can also use your favorite package manager.
### Installing via a Package Manager
On Windows:
```
> choco install nats-server
```
On Mac OS:
```
> brew install nats-server
```
Via Docker:
```
> docker pull nats-server:latest
```
### Installing directly Release Build
You can find the latest release of nats-server [here](https://github.com/nats-io/nats-server/releases/latest).
Simply download the zip file matching your systems architecture, and unzip. For this example, assuming version 2.0.0 of the server, and a Linux AMD64:
```
> curl -L https://github.com/nats-io/nats-server/releases/download/v2.0.0/nats-server-v2.0.0-linux-amd64.zip -o nats-server.zip
> unzip nats-server.zip -d nats-server
Archive: nats-server.zip
creating: nats-server-v2.0.0-darwin-amd64/
inflating: nats-server-v2.0.0-darwin-amd64/README.md
inflating: nats-server-v2.0.0-darwin-amd64/LICENSE
inflating: nats-server-v2.0.0darwin-amd64/nats-server
> cp nats-server-v2.0.0darwin-amd64/nats-server /usr/local/bin
```
### Installing from the source
If you have go installed, installing the binary is very easy:
```
> go get github.com/nats-io/nats-server
```
This mechanism will always install the latest build on [master](https://github.com/nats-io/nats-server), which almost certainly will not be a released version. If you are a developer and want to play with the the latest, this is the easiest way of obtaining it.
## Testing Your Installation
To test your installation (provided the install locations are visible by your shell):
```
> nats-server
[41634] 2019/05/13 09:42:11.745919 [INF] Starting nats-server version 2.0.0
[41634] 2019/05/13 09:42:11.746240 [INF] Listening for client connections on 0.0.0.0:4222
...
[41634] 2019/05/13 09:42:11.746249 [INF] Server id is NBNYNR4ZNTH4N2UQKSAAKBAFLDV3PZO4OUYONSUIQASTQT7BT4ZF6WX7
[41634] 2019/05/13 09:42:11.746252 [INF] Server is ready
```

34
nats_server/running.md Normal file
View File

@@ -0,0 +1,34 @@
## Running
The nats-server has many command line options. To get started, you don't have to specify anything.
In the absence of any flags, the NATS server will start listening for NATS client connections on port 4222.
By default, security is not enabled.
### Standalone
When the server starts it will print some information including where the server is listening for client connections:
```
> nats-server
[41634] 2019/05/13 09:42:11.745919 [INF] Starting nats-server version 2.0.0
[41634] 2019/05/13 09:42:11.746240 [INF] Listening for client connections on 0.0.0.0:4222
...
[41634] 2019/05/13 09:42:11.746249 [INF] Server id is NBNYNR4ZNTH4N2UQKSAAKBAFLDV3PZO4OUYONSUIQASTQT7BT4ZF6WX7
[41634] 2019/05/13 09:42:11.746252 [INF] Server is ready
```
### Docker
If you are running your NATS server in a docker container:
```
> docker run -p 4222:4222 -ti nats-server:latest
[1] 2019/05/13 14:55:11.981434 [INF] Starting nats-server version 2.0.0
...
[1] 2019/05/13 14:55:11.981545 [INF] Starting http monitor on 0.0.0.0:8222
[1] 2019/05/13 14:55:11.981560 [INF] Listening for client connections on 0.0.0.0:4222
[1] 2019/05/13 14:55:11.981565 [INF] Server is ready
[1] 2019/05/13 14:55:11.982492 [INF] Listening for route connections on 0.0.0.0:6222
...
```