Compare commits

...

10 commits

Author SHA1 Message Date
Todd Treece
83cdba7806 1.1.1 2017-03-05 10:11:51 -05:00
Todd Treece
78b7f289b7 Merge pull request #1 from peet86/master
wrong execution path for index.js - fixed
2017-03-04 15:11:02 -05:00
Peter Varga
d720686048 wrong execution path for index.js - fixed 2016-11-27 14:29:14 +01:00
Todd Treece
af0a6f4087 1.1.0 2016-11-10 11:11:48 -05:00
Todd Treece
bd3bd90121 update install instructions in README 2016-11-10 11:11:29 -05:00
Todd Treece
156b36c67d replace forever with pm2 2016-11-10 11:11:14 -05:00
Todd Treece
26e1a00c4f 1.0.10 2015-08-18 12:57:26 -04:00
Todd Treece
3b801b1680 adds new tutorial link to readme 2015-08-18 12:57:16 -04:00
Todd Treece
5e401b0d27 1.0.9 2015-08-18 09:06:49 -04:00
Todd Treece
09d6278ae4 exit cli process when spawned child exits 2015-08-18 09:06:00 -04:00
3 changed files with 39 additions and 29 deletions

View file

@ -8,12 +8,12 @@ Make sure you have the latest stable version of [Node.js][3] installed on your c
```console
$ node -v
v0.12.6
v7.0.0
```
Install `forever` and `xcarve-proxy` on your computer using `npm`.
Install `xcarve-proxy` on your computer using `npm`.
```console
$ npm install -g forever xcarve-proxy
$ npm install -g xcarve-proxy
```
## Starting the Proxy
@ -43,7 +43,7 @@ stopping proxy...
```
## License
Copyright (c) 2015 Adafruit Industries. Licensed under the MIT license.
Copyright (c) 2015-2016 Adafruit Industries. Licensed under the MIT license.
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing products
@ -52,4 +52,4 @@ from [Adafruit](https://adafruit.com)!
[1]: https://github.com/adafruit/xcarve-server
[2]: http://easel.inventables.com
[3]: https://nodejs.org
[4]: https://learn.adafruit.com/control-an-xcarve-wirelessly
[4]: https://learn.adafruit.com/control-an-xcarve-cnc-machine-wirelessly-with-a-raspberry-pi

53
cli
View file

@ -1,42 +1,53 @@
#!/usr/bin/env node
var spawn = require('child_process').spawn,
var pm2 = require('pm2'),
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);
pm2.connect((err) => {
if(err) {
console.error(err);
process.exit(2);
}
pm2.start({
script: path.join(__dirname,'index.js'),
name: 'xcarve'
}, (err, apps) => {
pm2.disconnect();
if (err) throw err
console.log('starting proxy on port 1338...\n');
});
});
}
function stop() {
var child = spawn(command, ['stop', '-c', 'node', 'index.js', '-s'], {
cwd: __dirname,
env: process.env,
detached: true
pm2.connect((err) => {
if(err) {
console.error(err);
process.exit(2);
}
pm2.stop('xcarve', (err) => {
if(err) throw err;
console.log('stopping proxy...');
process.exit();
});
});
console.log('stopping proxy...');
child.on('error', console.log);
}
cli.version(package.version);
@ -47,5 +58,3 @@ cli.parse(process.argv);
if (!process.argv.slice(2).length) {
cli.outputHelp();
}
process.exit();

View file

@ -1,6 +1,6 @@
{
"name": "xcarve-proxy",
"version": "1.0.8",
"version": "1.1.1",
"description": "A Node.js proxy server for connecting to a Raspberry Pi that is running xcarve-server.",
"bin": "./cli",
"scripts": {
@ -24,6 +24,7 @@
"homepage": "https://github.com/adafruit/xcarve-proxy",
"dependencies": {
"commander": "^2.8.1",
"http-proxy": "^1.11.1"
"http-proxy": "^1.11.1",
"pm2": "^2.1.4"
}
}