Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
audstanley committed Jan 7, 2018
1 parent 8386ca2 commit bb45ba1
Showing 1 changed file with 192 additions and 1 deletion.
193 changes: 192 additions & 1 deletion rover/core/servers/Deepstream/ds-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,195 @@ Ports the DS rover server will listen on:

First install dependencies: `npm install`

Start the server: `npm start`
Start the server: `npm start`

-----

# Universal Method to install and run deepstream:
This process is necessary if you are running deepstream on a raspberry pi.

## FIRST, Make sure you have NodeJs installed:
For NodeJs on a raspberry pi go [here](https://github.com/audstanley/NodeJs-Raspberry-Pi) and copy paste into your cli to install NodeJs.
For Linux, Windows or Mac just use the installers [here](https://nodejs.org/en/)

## The Linux Guide (raspberry pi, x86 or x64):
### Clone the project:
I like to keep deepstream in my Documents folder:

```sh
cd ~/Documents/;
git clone https://github.com/deepstreamIO/deepstream.io;
cd deepstream.io/;
git submodule update --init
npm i;
npm start;
```

```sh
# Install pm2 also, which we will need later to start deepstream on startup
sudo npm install pm2 -g;
```


At this point, you are running deepstream, but we have some config files in deepstream that we want to edit. First go ahead and crash deepstream ctrl-c, and let's look at the deepstream file tree:

```
├── appveyor.yml
├── ascii-logo.txt
├── benchmarks
├── bin
├── CHANGELOG.md
├── conf <-- need to change conf/config.yml
├── dist <-- we will launch dist/bin/deepstream on startup.
├── elton-square.png
├── jasmine.json
├── jasmine-runner.js
├── LICENSE
├── node_modules
├── package.json
├── package-lock.json
├── protocol
├── README.md
├── scripts
├── src
├── test
├── test-e2e
├── tsconfig.json
└── tslint.json
```

you are going to want to open **conf/config.yml** and edit lines ~21 and ~47:

```
Example...
...
16 connectionEndpoints:
17 websocket:
18 type: default
19 options:
20 # port for the websocket server
21 port: 4020 # FOR TITANROVER
22 # host for the websocket server
23 host: 0.0.0.0
24 # url path websocket connections connect to
25 urlPath: /deepstream
26 # url path for http health-checks, GET requests to this path will return 200 if deepstream is alive
27 healthCheckPath: /health-check
28 # the amount of milliseconds between each ping/heartbeat message
29 heartbeatInterval: 30000
30 # the amount of milliseconds that writes to sockets are buffered
31 outgoingBufferTimeout: 0
32
33 # Security
34 # amount of time a connection can remain open while not being logged in
35 # or false for no timeout
36 unauthenticatedClientTimeout: 180000
37 # invalid login attempts before the connection is cut
38 maxAuthAttempts: 3
39 # if true, the logs will contain the cleartext username / password of invalid login attempts
40 logInvalidAuthData: false
41 # maximum allowed size of an individual message in bytes
42 maxMessageSize: 1048576
43 http:
44 type: default
45 options:
46 # port for the http server
47 port: 4080 # FOR TITANROVER
48 # host for the http server
49 host: 0.0.0.0
50 # allow 'authData' parameter in POST requests, if disabled only token and OPEN auth is
51 # possible
52 allowAuthData: true
53 # enable the authentication endpoint for requesting tokens/userData.
54 # note: a custom authentication handler is required for token generation
55 enableAuthEndpoint: false
56 # path for authentication requests
57 authPath: /auth
58 # path for POST requests
59 postPath: /
60 # path for GET requests
61 getPath: /
...
```

line 21 should be:
```
port: 4020
```
line 47 should be:
```
port: 4080
```
Save the file, and now let's setup deepstream to automatically run on startup.

```sh
# First you will need to bee your root user
sudo su;
# Change into the deepstream.io/dist/bin/ folder:
cd dist/bin/;
# add deepstream to the pm2
pm2 start deepstream --name deepstream;
# save the pm2 settings
pm2 save;
# add the startup process to pm2
pm2 startup;

# Now if you want to check pm2 to see if deepstream is running, just make sure you are root and...
pm2 ls;
```
You should see something like this:

```
┌────────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├────────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
│ deepstream │ 0 │ fork │ 1552 │ online │ 0 │ 4h │ 0% │ 74.2 MB │ root │ disabled │
└────────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
Use `pm2 show <id|name>` to get more details about an app
```

If you want to view the logs for deepstream, just sudo su, then you can view deepstream logs:

```
pm2 log deepstream;
```

You should see this:

```
audstanley-G750JM bin # pm2 log deepstream
[TAILING] Tailing last 15 lines for [deepstream] process (change the value with --lines option)
/root/.pm2/logs/deepstream-error-0.log last 15 lines:
/root/.pm2/logs/deepstream-out-0.log last 15 lines:
0|deepstre | ===================== starting =====================
0|deepstre | INFO | logger ready: std out/err
0|deepstre | INFO | deepstream version: 4.0.0-beta.2
0|deepstre | INFO | configuration file loaded from ../conf/config.yml
0|deepstre | INFO | authenticationHandler ready: none
0|deepstre | INFO | cache ready: local cache
0|deepstre | INFO | storage ready: noop storage
0|deepstre | INFO | permissionHandler ready: valve permissions loaded from /home/audstanley/Documents/deepstream.io/dist/conf/permissions.yml
0|deepstre | INFO | Listening for websocket connections on 0.0.0.0:4020/deepstream
0|deepstre | INFO | Listening for health checks on path /health-check
0|deepstre | INFO | connectionEndpoint ready: µWebSocket Connection Endpoint
0|deepstre | INFO | Listening for http connections on 0.0.0.0:4080
0|deepstre | INFO | Listening for health checks on path /health-check
0|deepstre | INFO | connectionEndpoint ready: HTTP connection endpoint
0|deepstre | INFO | Deepstream started
```

Ctrl-C to get out of viewing the log.

```sh
# To log out of root user:
exit;
```


## Windows Guide:
todo;

## Mac Guide:
todo;

0 comments on commit bb45ba1

Please sign in to comment.