itns-sidechain/bin/hsd
2019-04-01 06:25:41 -07:00

62 lines
1 KiB
JavaScript
Executable file

#!/usr/bin/env node
'use strict';
const execPath = process.execPath || process.argv[0];
const execArgv = process.execArgv || [];
const {argv, exit, stdout} = process;
/*
* Main
*/
function main() {
if (argv.length > 2) {
switch (argv[2]) {
case 'cli':
argv.splice(2, 1);
require('./cli');
return;
case 'wallet':
require('./cli');
return;
case 'rpc':
require('./cli');
return;
}
}
if (!argv.includes('--daemon')) {
if (argv.includes('--spv'))
require('./spvnode');
else
require('./node');
return;
}
const {spawn} = require('child_process');
const {resolve} = require('path');
const node = argv.includes('--spv') ? 'spvnode' : 'node';
const args = [];
args.push(...execArgv);
args.push(resolve(__dirname, node));
args.push(...argv.slice(2));
const ps = spawn(execPath, args, {
stdio: 'ignore',
detached: true
});
stdout.write(ps.pid + '\n');
exit(0);
}
/*
* Execute
*/
main();