Compare commits
16 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83cdba7806 | ||
|
|
78b7f289b7 | ||
|
|
d720686048 | ||
|
|
af0a6f4087 | ||
|
|
bd3bd90121 | ||
|
|
156b36c67d | ||
|
|
26e1a00c4f | ||
|
|
3b801b1680 | ||
|
|
5e401b0d27 | ||
|
|
09d6278ae4 | ||
|
|
c78ca3ac69 | ||
|
|
1dc0dd75d4 | ||
|
|
45e24168bb | ||
|
|
2d024e0510 | ||
|
|
e62edcc175 | ||
|
|
5aa8eca4ea |
5 changed files with 46 additions and 34 deletions
20
README.md
20
README.md
|
|
@ -1,25 +1,26 @@
|
||||||
# XCarve Proxy
|
# XCarve Proxy
|
||||||
A Node.js proxy server for connecting to a remote XCarve via a Raspberry Pi that is running [xcarve-server][1].
|
A Node.js proxy server for connecting to a remote XCarve via a Raspberry Pi that is running [xcarve-server][1].
|
||||||
|
For detailed install instructions, please visit the tutorial on the [Adafruit Learning System][4].
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Make sure you have the latest stable version of [Node.js][3] installed on your computer.
|
Make sure you have the latest stable version of [Node.js][3] installed on your computer.
|
||||||
|
|
||||||
```
|
```console
|
||||||
$ node -v
|
$ 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
|
## Starting the Proxy
|
||||||
Make sure you have [xcarve-server][1] running on your Raspberry Pi before continuing. If everything has
|
Make sure you have [xcarve-server][1] running on your Raspberry Pi before continuing. If everything has
|
||||||
been setup properly, you can start the proxy daemon by running the following command:
|
been setup properly, you can start the proxy daemon by running the following command:
|
||||||
|
|
||||||
```
|
```console
|
||||||
$ xcarve-proxy start
|
$ xcarve-proxy start
|
||||||
|
|
||||||
██╗ ██╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗
|
██╗ ██╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗
|
||||||
|
|
@ -32,17 +33,17 @@ $ xcarve-proxy start
|
||||||
starting proxy on port 1338...
|
starting proxy on port 1338...
|
||||||
```
|
```
|
||||||
|
|
||||||
Visit [easel.inventables.com][2] to test out the proxy.
|
Visit [easel.inventables.com][2] to test the proxy.
|
||||||
|
|
||||||
## Stopping the Proxy
|
## Stopping the Proxy
|
||||||
|
|
||||||
```
|
```console
|
||||||
$ xcarve-proxy stop
|
$ xcarve-proxy stop
|
||||||
stopping proxy...
|
stopping proxy...
|
||||||
```
|
```
|
||||||
## License
|
## 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,
|
Adafruit invests time and resources providing this open source code,
|
||||||
please support Adafruit and open-source hardware by purchasing products
|
please support Adafruit and open-source hardware by purchasing products
|
||||||
|
|
@ -51,3 +52,4 @@ from [Adafruit](https://adafruit.com)!
|
||||||
[1]: https://github.com/adafruit/xcarve-server
|
[1]: https://github.com/adafruit/xcarve-server
|
||||||
[2]: http://easel.inventables.com
|
[2]: http://easel.inventables.com
|
||||||
[3]: https://nodejs.org
|
[3]: https://nodejs.org
|
||||||
|
[4]: https://learn.adafruit.com/control-an-xcarve-cnc-machine-wirelessly-with-a-raspberry-pi
|
||||||
|
|
|
||||||
52
cli
52
cli
|
|
@ -1,44 +1,53 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
var spawn = require('child_process').spawn,
|
var pm2 = require('pm2'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
logo = fs.readFileSync(path.join(__dirname,'logo.txt'), 'utf8'),
|
logo = fs.readFileSync(path.join(__dirname,'logo.txt'), 'utf8'),
|
||||||
cli = require('commander'),
|
cli = require('commander'),
|
||||||
package = require('./package.json');
|
package = require('./package.json');
|
||||||
|
|
||||||
|
|
||||||
var command = process.platform === 'win32' ? 'forever.cmd' : 'forever';
|
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
|
|
||||||
process.chdir(path.normalize(__dirname));
|
|
||||||
|
|
||||||
var child = spawn(command, ['start', '-c', 'node', 'index.js', '-s'], {
|
|
||||||
env: process.env,
|
|
||||||
detached: true
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(logo);
|
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() {
|
function stop() {
|
||||||
|
|
||||||
process.chdir(path.normalize(__dirname));
|
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();
|
||||||
|
});
|
||||||
|
|
||||||
var child = spawn(command, ['stop', '-c', 'node', 'index.js', '-s'], {
|
|
||||||
env: process.env,
|
|
||||||
detached: true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('stopping proxy...');
|
|
||||||
|
|
||||||
child.on('error', console.log);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cli.version(package.version);
|
cli.version(package.version);
|
||||||
|
|
@ -49,4 +58,3 @@ cli.parse(process.argv);
|
||||||
if (!process.argv.slice(2).length) {
|
if (!process.argv.slice(2).length) {
|
||||||
cli.outputHelp();
|
cli.outputHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
index.js
2
index.js
|
|
@ -1,6 +1,6 @@
|
||||||
var util = require('util'),
|
var util = require('util'),
|
||||||
httpProxy = require('http-proxy'),
|
httpProxy = require('http-proxy'),
|
||||||
host = 'xcarve.local',
|
host = (process.platform === 'win32' ? 'xcarve' : 'xcarve.local'),
|
||||||
port = 1338;
|
port = 1338;
|
||||||
|
|
||||||
var server = httpProxy.createServer({
|
var server = httpProxy.createServer({
|
||||||
|
|
|
||||||
1
logo.txt
1
logo.txt
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
██╗ ██╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗
|
██╗ ██╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗
|
||||||
╚██╗██╔╝ ██╔════╝██╔══██╗██╔══██╗██║ ██║██╔════╝
|
╚██╗██╔╝ ██╔════╝██╔══██╗██╔══██╗██║ ██║██╔════╝
|
||||||
╚███╔╝█████╗██║ ███████║██████╔╝██║ ██║█████╗
|
╚███╔╝█████╗██║ ███████║██████╔╝██║ ██║█████╗
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "xcarve-proxy",
|
"name": "xcarve-proxy",
|
||||||
"version": "1.0.5",
|
"version": "1.1.1",
|
||||||
"description": "A Node.js proxy server for connecting to a Raspberry Pi that is running xcarve-server.",
|
"description": "A Node.js proxy server for connecting to a Raspberry Pi that is running xcarve-server.",
|
||||||
"bin": "./cli",
|
"bin": "./cli",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
"homepage": "https://github.com/adafruit/xcarve-proxy",
|
"homepage": "https://github.com/adafruit/xcarve-proxy",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": "^2.8.1",
|
"commander": "^2.8.1",
|
||||||
"http-proxy": "^1.11.1"
|
"http-proxy": "^1.11.1",
|
||||||
|
"pm2": "^2.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue