From 71d6bb3b5428f4dbcf50485da83b14aa6d847b76 Mon Sep 17 00:00:00 2001 From: rajeshjayaraman Date: Wed, 17 Jun 2015 10:58:58 -0400 Subject: [PATCH 1/5] Creating wrapper shell scripts for starting and stopping all the requisite services needed to run BWS --- start.sh | 31 +++++++++++++++++++++++++++++++ stop.sh | 18 ++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 start.sh create mode 100755 stop.sh diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..454ff1d --- /dev/null +++ b/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 + diff --git a/stop.sh b/stop.sh new file mode 100755 index 0000000..4b80f0b --- /dev/null +++ b/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 + From 92880fa268b992e9b3c4e055a24dfc44b4570ddf Mon Sep 17 00:00:00 2001 From: rajeshjayaraman Date: Wed, 17 Jun 2015 11:15:21 -0400 Subject: [PATCH 2/5] gitignore to include .idea --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7bae1b2..c79a112 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ out/ db/* multilevel/db/* +.idea \ No newline at end of file From 781b0e5ae6ab306074c6dd2a748ca64bd7f617fb Mon Sep 17 00:00:00 2001 From: rajeshjayaraman Date: Wed, 17 Jun 2015 12:06:46 -0400 Subject: [PATCH 3/5] Updating documentation & package.json to reflect usage of start.sh and stop.sh --- installation.md | 75 ++++++++++++++++++++++++++----------------------- package.json | 3 +- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/installation.md b/installation.md index febad44..ff894a9 100644 --- a/installation.md +++ b/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. +### 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 from github source +Use the following steps to Install BWS from github source and run it with defaults. +```bash +git clone https://github.com/bitpay/bitcore-wallet-service.git +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 +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 Insight service hosted by Bitpay) +Email Service - emailservice/emailservice.js +Bitcore Wallet Service - bws.js -###Install BWS -```bash -npm install bws -cd bws -```` - -###Start MongoDB +#### Configure MongoDB Example configuration for connecting to the MongoDB instance: ```javascript storageOpts: { @@ -18,11 +45,7 @@ Example configuration for connecting to the MongoDB instance: }, } ``` - -###Start locker service -```bash -node locker/locker.js -```` +#### Configure Locker service Example configuration for connecting to locker service: ```javascript lockOpts: { @@ -33,10 +56,7 @@ Example configuration for connecting to locker service: } ``` -###Start message broker service -```bash -node messagebroker/messagebroker.js -```` +#### Configure Message Broker service Example configuration for connecting to message broker service: ```javascript 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. An example of this configuration is: ```javascript @@ -62,18 +82,7 @@ An example of this configuration is: } ``` - -###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 -```` +#### Configure Email service Example configuration for connecting to email service (using postfix): ```javascript 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: ```javascript { @@ -94,7 +103,3 @@ Change `config.js` file to enable and configure clustering: } ``` -###Start bws instances -```bash -npm start -```` diff --git a/package.json b/package.json index e88810a..42c74cf 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "tingodb": "^0.3.4" }, "scripts": { - "start": "node bws.js", + "start": "./start.sh", + "stop": "./stop.sh", "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test", "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" From dc15717de557fe44d36dd17383392a81fe3ff738 Mon Sep 17 00:00:00 2001 From: rajeshjayaraman Date: Wed, 17 Jun 2015 15:34:00 -0400 Subject: [PATCH 4/5] corrected note about blockchain explorer service --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index ff894a9..0ef4c5b 100644 --- a/installation.md +++ b/installation.md @@ -32,7 +32,7 @@ Configuration for all required modules can be specified in https://github.com/bi 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 Insight service hosted by Bitpay) +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 From 7b3068711538db01d0f93e750d9e74c1feb8e65d Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Thu, 18 Jun 2015 11:59:03 -0300 Subject: [PATCH 5/5] bitcore 0.12.9, bwu 0.0.16 --- package.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 42c74cf..99b9eed 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "bitcore-wallet-service", "description": "A service for Mutisig HD Bitcoin Wallets", "author": "BitPay Inc", - "version": "0.0.34", + "version": "0.0.35", "keywords": [ "bitcoin", "copay", @@ -19,9 +19,8 @@ }, "dependencies": { "async": "^0.9.0", - "bitcore": "git://github.com/bitpay/bitcore.git#a4ac3f50d300b3f89fad02f9e38fc536ac90abdc", - "bitcore-explorers": "^0.10.3", - "bitcore-wallet-utils": "0.0.15", + "bitcore": "^0.12.9", + "bitcore-wallet-utils": "0.0.16", "body-parser": "^1.11.0", "coveralls": "^2.11.2", "email-validator": "^1.0.1",