You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.4 KiB
63 lines
2.4 KiB
8 years ago
|
#!/usr/bin/env node
|
||
|
var Router = require('./router')
|
||
|
var program = require('commander')
|
||
7 years ago
|
var startmistGeth = require('./services/startMistGeth')
|
||
|
var startFrontend = require('./services/startFrontend')
|
||
|
var fs = require('fs-extra')
|
||
|
|
||
8 years ago
|
program
|
||
7 years ago
|
.usage('-s <shared folder>')
|
||
8 years ago
|
.description('Provide a two ways connection between the local computer and Remix IDE')
|
||
7 years ago
|
.option('-s, --shared-folder <path>', 'Folder to share with Remix IDE')
|
||
|
.option('-m, --mist', 'start mist')
|
||
|
.option('-g, --geth', 'start geth')
|
||
|
.option('-p, --dev-path <dev-path>', 'Folder used by mist/geth to start the development instance')
|
||
|
.option('-f, --frontend <front-end>', 'Folder that should be served by remixd')
|
||
|
.option('-p, --frontend-port <front-end-port>', 'Http port used by the frontend (default 8082)')
|
||
|
.option('-a, --auto-mine', 'mine pending transactions')
|
||
7 years ago
|
.option('-r, --rpc <cors-domains>', 'start rpc server. Values are CORS domain')
|
||
|
.option('-rp, --rpc-port', 'rpc server port (default 8545)')
|
||
8 years ago
|
.parse(process.argv)
|
||
7 years ago
|
console.log('example: --dev-path /home/devchains/chain1 --mist --geth --frontend /home/frontend --frontend-port 8084 --auto-mine')
|
||
|
program.outputHelp()
|
||
|
|
||
|
var killCallBack = []
|
||
|
|
||
|
if (program.devPath) {
|
||
|
if (fs.existsSync(program.devPath)) {
|
||
7 years ago
|
killCallBack.push(startmistGeth(program.devPath, program.mist, program.geth, program.autoMine, program.rpc, program.rpcPort))
|
||
7 years ago
|
} else {
|
||
|
console.log('\x1b[31m%s\x1b[0m', '[ERR] can\'t start mist/geth. ' + program.devPath + ' does not exist')
|
||
|
}
|
||
|
}
|
||
8 years ago
|
|
||
7 years ago
|
if (program.frontend) {
|
||
|
if (!program.frontendPort) program.frontendPort = 8082
|
||
|
if (fs.existsSync(program.frontend)) {
|
||
|
killCallBack.push(startFrontend(program.frontend, program.frontendPort))
|
||
|
} else {
|
||
|
console.log('\x1b[31m%s\x1b[0m', '[ERR] can\'t start frontend. ' + program.frontend + ' does not exist')
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (program.sharedFolder) {
|
||
7 years ago
|
console.log('\x1b[33m%s\x1b[0m', '[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.')
|
||
|
console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolinc links are not forwarded to Remix IDE\n')
|
||
7 years ago
|
var router = new Router()
|
||
7 years ago
|
killCallBack.push(router.start(program.sharedFolder))
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
// kill
|
||
|
function kill () {
|
||
|
for (var k in killCallBack) {
|
||
|
try {
|
||
|
killCallBack[k]()
|
||
|
} catch (e) {
|
||
|
console.log(e)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
process.on('SIGINT', kill) // catch ctrl-c
|
||
|
process.on('SIGTERM', kill) // catch kill
|
||
|
process.on('exit', kill)
|