Merge pull request #1 from cubedro/develop

Websockets login
This commit is contained in:
Marian OANCΞA 2015-02-26 23:48:58 +02:00
commit 524b163391
4 changed files with 34 additions and 16 deletions

View File

@ -18,18 +18,9 @@ Fetch and run the build shell. This will install everything you need: latest cpp
curl https://raw.githubusercontent.com/cubedro/eth-net-intelligence-api/master/bin/build.sh | sh curl https://raw.githubusercontent.com/cubedro/eth-net-intelligence-api/master/bin/build.sh | sh
``` ```
## Run
Run it using pm2:
```
cd ~/bin/www
pm2 start processes.json
```
## Configuration ## Configuration
Configure the app in [processes.json](/eth-net-intelligence-api/blob/master/processes.json) Configure the app modifying [processes.json](/eth-net-intelligence-api/blob/master/processes.json). Note that you have to modify the backup processes.json file located in `./bin/processes.json` (to allow you to set your env vars without being rewritten when updating).
``` ```
"env": "env":
@ -38,9 +29,33 @@ Configure the app in [processes.json](/eth-net-intelligence-api/blob/master/proc
"RPC_HOST" : "localhost", // eth JSON-RPC host "RPC_HOST" : "localhost", // eth JSON-RPC host
"RPC_PORT" : "8080", // eth JSON-RPC port "RPC_PORT" : "8080", // eth JSON-RPC port
"WS_SERVER" : "", // path to eth-netstats WebSockets api server "WS_SERVER" : "", // path to eth-netstats WebSockets api server
"WS_SECRET" : "", // WebSockets api server secret used for login
} }
``` ```
## Run
Run it using pm2:
```
cd ~/bin
pm2 start processes.json
```
## Updating
To update the API client use the following commands:
```
pm2 kill
cd ~/bin/www
git pull
sudo npm update
sudo npm install
cd ..
pm2 start processes.json
```
[travis-image]: https://travis-ci.org/cubedro/eth-net-intelligence-api.svg [travis-image]: https://travis-ci.org/cubedro/eth-net-intelligence-api.svg
[travis-url]: https://travis-ci.org/cubedro/eth-net-intelligence-api [travis-url]: https://travis-ci.org/cubedro/eth-net-intelligence-api
[dep-image]: https://david-dm.org/cubedro/eth-net-intelligence-api.svg [dep-image]: https://david-dm.org/cubedro/eth-net-intelligence-api.svg

View File

@ -54,4 +54,4 @@ cd www
sudo npm install sudo npm install
sudo npm install pm2 -g sudo npm install pm2 -g
pm2 start processes.json cp -b ./processes.json ./..

View File

@ -74,7 +74,7 @@ function Node()
web3.setProvider(new web3.providers.HttpSyncProvider('http://' + (process.env.RPC_HOST || 'localhost') + ':' + (process.env.RPC_PORT || '8080'))); web3.setProvider(new web3.providers.HttpSyncProvider('http://' + (process.env.RPC_HOST || 'localhost') + ':' + (process.env.RPC_PORT || '8080')));
socket.on('open', function open() { socket.on('open', function open() {
socket.emit('hello', { id: self.id, info: self.info}); socket.emit('hello', { id: self.id, info: self.info, secret: process.env.WS_SECRET });
console.log('The connection has been opened.'); console.log('The connection has been opened.');
}).on('end', function end() { }).on('end', function end() {
self._socket = false; self._socket = false;
@ -92,7 +92,7 @@ function Node()
self.sendUpdate(true); self.sendUpdate(true);
console.log('The connection has been established.'); console.log('The connection has been established.');
}) });
this.init(); this.init();

View File

@ -1,7 +1,8 @@
[ [
{ {
"name" : "eth", "name" : "eth",
"script" : "./bin/eth.sh", "cwd" : "/home/ubuntu/bin/www/",
"script" : "bin/eth.sh",
"log_file" : "/home/ubuntu/logs/eth-log.log", "log_file" : "/home/ubuntu/logs/eth-log.log",
"out_file" : "/home/ubuntu/logs/eth-out.log", "out_file" : "/home/ubuntu/logs/eth-out.log",
"error_file" : "/home/ubuntu/logs/eth-err.log", "error_file" : "/home/ubuntu/logs/eth-err.log",
@ -13,7 +14,8 @@
}, },
{ {
"name" : "node-app", "name" : "node-app",
"script" : "./app.js", "cwd" : "/home/ubuntu/bin/www/",
"script" : "app.js",
"log_file" : "/home/ubuntu/logs/node-app-log.log", "log_file" : "/home/ubuntu/logs/node-app-log.log",
"out_file" : "/home/ubuntu/logs/node-app-out.log", "out_file" : "/home/ubuntu/logs/node-app-out.log",
"error_file" : "/home/ubuntu/logs/node-app-err.log", "error_file" : "/home/ubuntu/logs/node-app-err.log",
@ -27,7 +29,8 @@
"NODE_ENV" : "production", "NODE_ENV" : "production",
"RPC_HOST" : "localhost", "RPC_HOST" : "localhost",
"RPC_PORT" : "8080", "RPC_PORT" : "8080",
"WS_SERVER" : "wss://eth-netstats.herokuapp.com", "WS_SERVER" : "",
"WS_SECRET" : "",
} }
} }
] ]