Merge pull request #245 from cmgustavo/feature/01-env-for-live-and-testnet

Feature/01 env for live and testnet
This commit is contained in:
Mario Colque 2014-02-11 18:13:23 -02:00
commit b5d1da06c8
7 changed files with 40 additions and 23 deletions

2
.gitignore vendored
View File

@ -29,7 +29,9 @@ npm-debug.log
.DS_Store .DS_Store
public/lib/* public/lib/*
db/txs/* db/txs/*
db/testnet/txs/*
db/blocks/* db/blocks/*
db/testnet/blocks/*
public/js/* public/js/*
public/css/* public/css/*

View File

@ -1,36 +1,47 @@
'use strict'; 'use strict';
/**
* Module dependencies.
*/
var path = require('path'), var path = require('path'),
rootPath = path.normalize(__dirname + '/..'), rootPath = path.normalize(__dirname + '/..'),
env; env,
db = './db/testnet',
port = '3000',
b_port = '18332',
p2p_port = '18333';
switch(process.env.NODE_ENV) { switch(process.env.NODE_ENV) {
case 'production': case 'production':
env = 'prod'; if (process.env.INSIGHT_NETWORK === 'livenet') {
break; env = 'livenet';
db = './db';
b_port = '8332';
p2p_port = '8333';
}
else {
env = 'testnet';
port = '3001';
}
break;
case 'test': case 'test':
env = 'test'; env = 'test environment';
break; break;
default: default:
env = 'dev'; env = 'development';
break; break;
} }
module.exports = { module.exports = {
root: rootPath, root: rootPath,
appName: 'Insight ' + env, appName: 'Insight ' + env,
port: process.env.PORT || 3000, port: port,
leveldb: './db', leveldb: db,
bitcoind: { bitcoind: {
protocol: process.env.BITCOIND_PROTO || 'http', protocol: process.env.BITCOIND_PROTO || 'http',
user: process.env.BITCOIND_USER || 'user', user: process.env.BITCOIND_USER || 'user',
pass: process.env.BITCOIND_PASS || 'pass', pass: process.env.BITCOIND_PASS || 'pass',
host: process.env.BITCOIND_HOST || '127.0.0.1', host: process.env.BITCOIND_HOST || '127.0.0.1',
port: process.env.BITCOIND_PORT || '18332', port: b_port,
p2pPort: process.env.BITCOIND_P2P_PORT || '18333', p2pPort: p2p_port,
dataDir: process.env.BITCOIND_DATADIR || (process.env.HOME + '/.bitcoin/' + dataDir: (process.env.BITCOIND_DATADIR +
((process.env.INSIGHT_NETWORK || 'testnet')==='testnet'?'testnet3':'')), ((process.env.INSIGHT_NETWORK || 'testnet')==='testnet'?'testnet3':'')),
// DO NOT CHANGE THIS! // DO NOT CHANGE THIS!

0
db/testnet/empty Normal file
View File

View File

@ -4,6 +4,7 @@ server=1
txindex=1 txindex=1
# Allow connections outsite localhost? # Allow connections outsite localhost?
#rpcallowip=192.168.1.* rpcallowip=192.168.1.*
#rpcallowip=127.0.0.1
#rpcallowip=* rpcport=8332

View File

@ -4,10 +4,7 @@ server=1
txindex=1 txindex=1
# Allow connections outsite localhost? # Allow connections outsite localhost?
#rpcallowip=192.168.1.* rpcallowip=192.168.1.*
#rpcallowip=127.0.0.1
#rpcallowip=*
port=18333
rpcport=18332 rpcport=18332
testnet=3 testnet=3

View File

@ -79,7 +79,8 @@
"chai": "~1.8.1", "chai": "~1.8.1",
"bitcore": "git://github.com/bitpay/bitcore.git", "bitcore": "git://github.com/bitpay/bitcore.git",
"bufferput": "git://github.com/bitpay/node-bufferput.git", "bufferput": "git://github.com/bitpay/node-bufferput.git",
"xmlhttprequest": "~1.6.0" "xmlhttprequest": "~1.6.0",
"pm2": "*"
}, },
"devDependencies": { "devDependencies": {
"grunt-contrib-watch": "latest", "grunt-contrib-watch": "latest",

5
start.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
NODE_ENV='production' INSIGHT_NETWORK='livenet' ./node_modules/pm2/bin/pm2 -f start insight.js --name insight-livenet &
sleep 10;
NODE_ENV='production' INSIGHT_NETWORK='testnet' ./node_modules/pm2/bin/pm2 -f start insight.js --name insight-testnet &