Browse Source

Merge remote-tracking branch 'upstream/master' into feat/multOutputs

activeAddress
Gregg Zigler 10 years ago
parent
commit
07a381bdb3
  1. 1
      .gitignore
  2. 73
      installation.md
  3. 10
      package.json
  4. 31
      start.sh
  5. 18
      stop.sh

1
.gitignore

@ -33,3 +33,4 @@ out/
db/* db/*
multilevel/db/* multilevel/db/*
.idea

73
installation.md

@ -1,15 +1,42 @@
The following document is a step-by-step guide to run BWS in cluster mode. The following document is a step-by-step guide to run BWS.
Configuration for all required modules can be specified in https://github.com/bitpay/bitcore-wallet-service/blob/master/config.js ### Prerequisites
Ensure MongoDB (2.6+) is installed and running. This document assumes that mongod is running at the default port 27017.
See the configuration section to configure a different host/port.
### Install BWS from NPM
Use the following steps to Install BWS from the npmjs repository and run it with defaults.
```bash
npm install bitcore-wallet-service
cd bitcore-wallet-service
```
To change configuration before running, see the Configuration section.
```bash
npm start
```
###Install BWS ### Install BWS from github source
Use the following steps to Install BWS from github source and run it with defaults.
```bash ```bash
npm install bws git clone https://github.com/bitpay/bitcore-wallet-service.git
cd bws cd bitcore-wallet-service
```` npm install
```
To change configuration before running, see the Configuration section.
```bash
npm start
```
### Configuration
Configuration for all required modules can be specified in https://github.com/bitpay/bitcore-wallet-service/blob/master/config.js
###Start MongoDB BWS is composed of 5 separate node services -
Locker - locker/locker.js
Message Broker - messagebroker/messagebroker.js
Blockchain Monitor - bcmonitor/bcmonitor.js (This service talks to the Blockchain Explorer service configured under blockchainExplorerOpts - see Configure blockchain service below.)
Email Service - emailservice/emailservice.js
Bitcore Wallet Service - bws.js
#### Configure MongoDB
Example configuration for connecting to the MongoDB instance: Example configuration for connecting to the MongoDB instance:
```javascript ```javascript
storageOpts: { storageOpts: {
@ -18,11 +45,7 @@ Example configuration for connecting to the MongoDB instance:
}, },
} }
``` ```
#### Configure Locker service
###Start locker service
```bash
node locker/locker.js
````
Example configuration for connecting to locker service: Example configuration for connecting to locker service:
```javascript ```javascript
lockOpts: { lockOpts: {
@ -33,10 +56,7 @@ Example configuration for connecting to locker service:
} }
``` ```
###Start message broker service #### Configure Message Broker service
```bash
node messagebroker/messagebroker.js
````
Example configuration for connecting to message broker service: Example configuration for connecting to message broker service:
```javascript ```javascript
messageBrokerOpts: { messageBrokerOpts: {
@ -46,7 +66,7 @@ Example configuration for connecting to message broker service:
} }
``` ```
###Configure blockchain service #### Configure blockchain service
Note: this service will be used by blockchain monitor service as well as by BWS itself. Note: this service will be used by blockchain monitor service as well as by BWS itself.
An example of this configuration is: An example of this configuration is:
```javascript ```javascript
@ -62,18 +82,7 @@ An example of this configuration is:
} }
``` ```
#### Configure Email service
###Start blockchain monitor service
The monitor service is used to notify instances of BWS of incoming txs. It will connect to all previous services so it is important that those are already running.
```bash
node bcmonitor/bcmonitor.js
````
###Start email service
```bash
node emailservice/emailservice.js
````
Example configuration for connecting to email service (using postfix): Example configuration for connecting to email service (using postfix):
```javascript ```javascript
emailOpts: { emailOpts: {
@ -85,7 +94,7 @@ Example configuration for connecting to email service (using postfix):
} }
``` ```
###Enable clustering #### Enable clustering
Change `config.js` file to enable and configure clustering: Change `config.js` file to enable and configure clustering:
```javascript ```javascript
{ {
@ -94,7 +103,3 @@ Change `config.js` file to enable and configure clustering:
} }
``` ```
###Start bws instances
```bash
npm start
````

10
package.json

@ -2,7 +2,7 @@
"name": "bitcore-wallet-service", "name": "bitcore-wallet-service",
"description": "A service for Mutisig HD Bitcoin Wallets", "description": "A service for Mutisig HD Bitcoin Wallets",
"author": "BitPay Inc", "author": "BitPay Inc",
"version": "0.0.34", "version": "0.0.35",
"keywords": [ "keywords": [
"bitcoin", "bitcoin",
"copay", "copay",
@ -19,9 +19,8 @@
}, },
"dependencies": { "dependencies": {
"async": "^0.9.0", "async": "^0.9.0",
"bitcore": "git://github.com/bitpay/bitcore.git#a4ac3f50d300b3f89fad02f9e38fc536ac90abdc", "bitcore": "^0.12.9",
"bitcore-explorers": "^0.10.3", "bitcore-wallet-utils": "0.0.16",
"bitcore-wallet-utils": "0.0.15",
"body-parser": "^1.11.0", "body-parser": "^1.11.0",
"coveralls": "^2.11.2", "coveralls": "^2.11.2",
"email-validator": "^1.0.1", "email-validator": "^1.0.1",
@ -57,7 +56,8 @@
"tingodb": "^0.3.4" "tingodb": "^0.3.4"
}, },
"scripts": { "scripts": {
"start": "node bws.js", "start": "./start.sh",
"stop": "./stop.sh",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test", "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test",
"test": "./node_modules/.bin/mocha", "test": "./node_modules/.bin/mocha",
"coveralls": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" "coveralls": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"

31
start.sh

@ -0,0 +1,31 @@
#!/bin/bash
mkdir -p logs
mkdir -p pids
# run_program (nodefile, pidfile, logfile)
run_program ()
{
nodefile=$1
pidfile=$2
logfile=$3
nohup node $nodefile >> $logfile 2>&1 &
PID=$!
if [ $? -eq 0 ]
then
echo "Successfully started $nodefile. PID=$PID. Logs are at $logfile"
echo $PID > $pidfile
return 0
else
echo "Could not start $nodefile - check logs at $logfile"
exit 1
fi
}
run_program locker/locker.js pids/locker.pid logs/locker.log
run_program messagebroker/messagebroker.js pids/messagebroker.pid logs/messagebroker.log
run_program bcmonitor/bcmonitor.js pids/bcmonitor.pid logs/bcmonitor.log
run_program emailservice/emailservice.js pids/emailservice.pid logs/emailservice.log
run_program bws.js pids/bws.pid logs/bws.log

18
stop.sh

@ -0,0 +1,18 @@
#!/bin/bash
stop_program ()
{
pidfile=$1
echo "Stopping Process - $pidfile. PID=$(cat $pidfile)"
kill -9 $(cat $pidfile)
rm $pidfile
}
stop_program pids/bws.pid
stop_program pids/emailservice.pid
stop_program pids/bcmonitor.pid
stop_program pids/messagebroker.pid
stop_program pids/locker.pid
Loading…
Cancel
Save