Browse Source

Add CLI utility

fix-133-memory-crash
Nadav Ivgi 6 years ago
parent
commit
8b175c8110
  1. 4
      app/defaultCredentials.js
  2. 55
      bin/cli.js
  3. 2
      bin/www
  4. 5
      package.json

4
app/defaultCredentials.js

@ -11,10 +11,10 @@ module.exports = {
},
influxdb:{
active: !!process.env.BTCEXP_INFLUXDB_ENABLED,
active: !!process.env.BTCEXP_ENABLE_INFLUXDB,
host: process.env.BTCEXP_INFLUXDB_HOST || "127.0.0.1",
port: process.env.BTCEXP_INFLUXDB_PORT || 8086,
database: process.env.BTCEXP_INFLUXDB_DB || "influxdb",
database: process.env.BTCEXP_INFLUXDB_DBNAME || "influxdb",
username: process.env.BTCEXP_INFLUXDB_USER || "admin",
password: process.env.BTCEXP_INFLUXDB_PASS || "admin"
},

55
bin/cli.js

@ -0,0 +1,55 @@
#!/usr/bin/env node
const args = require('meow')(`
Usage
$ btc-rpc-explorer [options]
Options
-p, --port <port> port to bind http server [default: 3002]
--coin <coin> crypto-coin to enable [default: BTC]
-H, --bitcoind-host <host> hostname for bitcoind rpc [default: 127.0.0.1]
-P, --bitcoind-port <port> port for bitcoind rpc [default: 8332]
-c, --bitcoind-cookie <path> path to bitcoind cookie file [default: 8332]
-u, --bitcoind-user <user> username for bitcoind rpc [default: none]
-w, --bitcoind-pass <pass> password for bitcoind rpc [default: none]
--cookie-password <secret> secret key for signed cookie hmac generation
--demo enable demoSite mode [default: disabled]
--ipstack-key <key> api access key for ipstack (for geoip) [default: disabled]
--ganalytics-tracking <tid> tracking id for google analytics [default: disabled]
--sentry-url <sentry-url> sentry url [default: disabled]
--enable-influxdb enable influxdb for logging network stats [default: false]
--influxdb-host <host> hostname for influxdb [default: 127.0.0.1]
--influxdb-user <user> username for influxdb [default: admin]
--influxdb-pass <pass> password for influxdb [default: admin]
--influxdb-dbname <db> database name for influxdb [default: influxdb]
-e, --node-env <env> nodejs environment mode [default: production]
-h, --help output usage information
-v, --version output version number
Example
$ btc-rpc-explorer --port 8080 --bitcoind-port 18443 --bitcoind-cookie ~/.bitcoin/regtest/.cookie
$ btc-rpc-explorer -p 8080 -P 18443 -c ~/.bitcoin/regtest.cookie
All options may also be specified as environment variables:
$ BTCEXP_PORT=8080 BTCEXP_BITCOIND_PORT=18443 BTCEXP_BITCOIND_COOKIE=~/.bitcoin/regtest/.cookie btc-rpc-explorer
`, { flags: { port: {alias:'p'}, enableInfluxdb: {type:'boolean'}, nodeEnv: {alias:'e', default:'production'}
, bitcoindHost: {alias:'H'}, bitcoindPort: {alias:'P'}, bitcoindCookie: {alias:'c'}
, bitcoindUser: {alias:'u'}, bitcoindPass: {alias:'w'}
, demo: {type:'boolean'}
} }
).flags;
const envify = k => k.replace(/([A-Z])/g, '_$1').toUpperCase();
Object.keys(args).filter(k => k.length > 1).forEach(k => {
if (args[k] === false) process.env[`BTCEXP_NO_${envify(k)}`] = true;
else process.env[`BTCEXP_${envify(k)}`] = args[k];
})
require('./www');

2
bin/www

@ -2,7 +2,7 @@
var debug = require('debug')('my-application');
var app = require('../app');
app.set('port', process.env.PORT || 3002);
app.set('port', process.env.PORT || process.env.BTCEXP_PORT || 3002);
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);

5
package.json

@ -3,10 +3,12 @@
"version": "1.0.0",
"description": "Explorer for Bitcoin and RPC-compatible blockchains",
"private": false,
"bin": "bin/cli.js",
"scripts": {
"start": "node ./bin/www",
"build": "npm-run-all build:*",
"build:less": "lessc ./public/css/radial-progress.less ./public/css/radial-progress.css"
"build:less": "lessc ./public/css/radial-progress.less ./public/css/radial-progress.css",
"prepare": "npm run build"
},
"keywords": [
"bitcoin",
@ -34,6 +36,7 @@
"influx": "5.0.7",
"jstransformer-markdown-it": "^2.0.0",
"lru-cache": "4.1.3",
"meow": "^5.0.0",
"moment": "^2.24.0",
"moment-duration-format": "2.2.2",
"morgan": "^1.9.1",

Loading…
Cancel
Save