55 lines
1.2 KiB
JavaScript
Executable file
55 lines
1.2 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
var spawn = require('child_process').spawn,
|
|
fs = require('fs'),
|
|
path = require('path'),
|
|
logo = fs.readFileSync(path.join(__dirname,'logo.txt'), 'utf8'),
|
|
cli = require('commander'),
|
|
package = require('./package.json');
|
|
|
|
|
|
var command = process.platform === 'win32' ? 'forever.cmd' : 'forever';
|
|
|
|
function start() {
|
|
|
|
var child = spawn(command, ['start', '-c', 'node', 'index.js', '-s'], {
|
|
cwd: __dirname,
|
|
env: process.env,
|
|
detached: true
|
|
});
|
|
|
|
console.log(logo);
|
|
console.log('starting proxy on port 1338...');
|
|
|
|
child.on('error', console.log);
|
|
child.on('exit', function(code) {
|
|
process.exit(code);
|
|
});
|
|
|
|
}
|
|
|
|
function stop() {
|
|
|
|
var child = spawn(command, ['stop', '-c', 'node', 'index.js', '-s'], {
|
|
cwd: __dirname,
|
|
env: process.env,
|
|
detached: true
|
|
});
|
|
|
|
console.log('stopping proxy...');
|
|
|
|
child.on('error', console.log);
|
|
child.on('exit', function(code) {
|
|
process.exit(code);
|
|
});
|
|
|
|
}
|
|
|
|
cli.version(package.version);
|
|
cli.command('start').description('starts the local xcarve proxy').action(start);
|
|
cli.command('stop').description('stops the local xcarve proxy').action(stop);
|
|
cli.parse(process.argv);
|
|
|
|
if (!process.argv.slice(2).length) {
|
|
cli.outputHelp();
|
|
}
|