Skip to content

Commit

Permalink
Catching exception, allowing continuation on error
Browse files Browse the repository at this point in the history
  • Loading branch information
ogt committed Jun 30, 2013
1 parent 4c3043a commit 676c3e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<tr style="height: 90%">
<td>
<label for="input">input</label><br>
<textarea id="input" class="input fill"> boo,*,23
<textarea id="input" class="input fill">boo,*,23
foo,*,32
poo,*,3
doo,*,2</textarea>
Expand Down
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ var createServer = require('http').createServer,

var port = process.env.PORT || 8000;

process.on('uncaughtException', function (err) {
try {
console.log('error: ' + (err.stack || err))
} catch (e) {}
});

function createCmdServer() {
return createServer(function (req, res) {
if (req.method == 'POST') {
var parsedUrl = parse(req.url,true, true),
args = [].concat(parsedUrl.query.args),
cmd = parsedUrl.pathname.replace('/','');
if (parsedUrl.query.args == '') args = null;
console.log('Executing',cmd,' with args ', args);
if (parsedUrl.query.args == '') args = null, console.log('Executing cmd')
else console.log('Executing',cmd,' with args ', args);
var proc = child(spawn(cmd, args));
req.pipe(proc)
.pipe(res);
Expand Down

0 comments on commit 676c3e2

Please sign in to comment.