From 1636e84bbedf0d88ac44258b939d946359a01bff Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 26 May 2014 13:29:52 -0300 Subject: [PATCH] add report when starting insight --- config/config.js | 63 +++++++++++++++++++++++++++++++++++++++--------- insight.js | 4 +-- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/config/config.js b/config/config.js index c89fc3a9..e2d80703 100644 --- a/config/config.js +++ b/config/config.js @@ -9,6 +9,9 @@ var path = require('path'), b_port, p2p_port; +var packageStr = fs.readFileSync('package.json'); +var version = JSON.parse(packageStr).version; + function getUserHome() { return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']; @@ -55,8 +58,54 @@ if (!dataDir) { if (isMac) dataDir = process.env.HOME + '/Library/Application Support/Bitcoin/'; if (isLinux) dataDir = process.env.HOME + '/.bitcoin/'; } +var odataDir = dataDir; + dataDir += network === 'testnet' ? 'testnet3' : ''; +var safeConfirmations = process.env.SAFE_CONFIRMATIONS || 6; + + +var bitcoindConf = { + protocol: process.env.BITCOIND_PROTO || 'http', + user: process.env.BITCOIND_USER || 'user', + pass: process.env.BITCOIND_PASS || 'pass', + host: process.env.BITCOIND_HOST || '127.0.0.1', + port: process.env.BITCOIND_PORT || b_port, + p2pPort: process.env.BITCOIND_P2P_PORT || p2p_port, + dataDir: dataDir, + // DO NOT CHANGE THIS! + disableAgent: true +}; + +/*jshint multistr: true */ +console.log( +'\n Insight API v%s\n\ +\n # Configuration:\n\ +\t\tNetwork: %s\tINSIGHT_NETWORK\n\ +\t\tDatabase Path: %s\tINSIGHT_DB\n\ +\t\tSafe Confirmations: %s\tSAFE_CONFIRMATIONS\n\ + # Bicoind Connection configuration:\n\ +\t\tRPC Username: %s\tBITCOIND_USER\n\ +\t\tRPC Password: %s\tBITCOIND_PASS\n\ +\t\tRPC Protocol: %s\tBITCOIND_PROTO\n\ +\t\tRPC Host: %s\tBITCOIND_HOST\n\ +\t\tRPC Port: %s\tBITCOIND_PORT\n\ +\t\tP2P Port: %s\tBITCOIND_P2P_PORT\n\ +\t\tData Dir: %s\tBITCOIND_DATADIR\n\ +\nChange setting by assigning the enviroment variables in the last column. Example:\n\ + $ INSIGHT_NETWORK="testnet" BITCOIND_HOST="123.123.123.123" ./insight.js\ +\n\n', +version, +network, home, safeConfirmations, +bitcoindConf.user, +bitcoindConf.pass?'Yes(hidden)':'No', +bitcoindConf.protocol, +bitcoindConf.host, +bitcoindConf.port, +bitcoindConf.p2p_port, +odataDir +); + if (! fs.existsSync(db)){ @@ -71,17 +120,7 @@ module.exports = { apiPrefix: '/api', port: port, leveldb: db, - bitcoind: { - protocol: process.env.BITCOIND_PROTO || 'http', - user: process.env.BITCOIND_USER || 'user', - pass: process.env.BITCOIND_PASS || 'pass', - host: process.env.BITCOIND_HOST || '127.0.0.1', - port: process.env.BITCOIND_PORT || b_port, - p2pPort: process.env.BITCOIND_P2P_PORT || p2p_port, - dataDir: dataDir, - // DO NOT CHANGE THIS! - disableAgent: true - }, + bitcoind: bitcoindConf, network: network, disableP2pSync: false, disableHistoricSync: false, @@ -92,5 +131,5 @@ module.exports = { keys: { segmentio: process.env.INSIGHT_SEGMENTIO_KEY }, - safeConfirmations: 6, // PLEASE NOTE THAT *FULL RESYNC* IS NEEDED TO CHANGE safeConfirmations + safeConfirmations: safeConfirmations, // PLEASE NOTE THAT *FULL RESYNC* IS NEEDED TO CHANGE safeConfirmations }; diff --git a/insight.js b/insight.js index 1cb74c08..215118db 100755 --- a/insight.js +++ b/insight.js @@ -1,6 +1,6 @@ +#!/usr/bin/env node + 'use strict'; - - //Set the node enviornment variable if not set before process.env.NODE_ENV = process.env.NODE_ENV || 'development';