I initialized the angular-fullstack code and was testing a child_process within the api server. I came to realize none of the endpoints are terminating.The child process and the code is executing but the endpoints remain open until I exit the curl command. The same applies with POSTMAN and the application.
The api code is executing but the curl is not terminating with status 200.
Code for GET
'use strict';
import jsonpatch from 'fast-json-patch';
import Pyrunner from './pyrunner.model';
import Promise from 'bluebird';
function respondWithResult(res, statusCode) {
statusCode = statusCode || 200;
console.log('pub')
return function(entity) {
console.log('sub')
console.log(entity + '2')
if (entity) {
return res.status(statusCode).json(entity);
}
return null;
};
}
function patchUpdates(patches) {
return function(entity) {
try {
// eslint-disable-next-line prefer-reflect
jsonpatch.apply(entity, patches, /*validate*/ true);
} catch (err) {
return Promise.reject(err);
}
return entity.save();
};
}
function removeEntity(res) {
return function(entity) {
if (entity) {
return entity.remove()
.then(() => {
res.status(204).end();
});
}
};
}
function handleEntityNotFound(res) {
return function(entity) {
if (!entity) {
res.status(404).end();
return null;
}
return entity;
};
}
function handleError(res, statusCode) {
statusCode = statusCode || 500;
return function(err) {
res.status(statusCode).send(err);
};
}
export function indexed(req, res) {
console.log('google')
var spawn = require('child_process').spawn;
var process = spawn('python', ["LM.v5.py"], {
cwd: __dirname
});
var output = "";
process.stdout.on('data', function(data) {
output += data
});
process.on('exit', function(code) {
if (code !== 0) {
return res.send(500, code);
}
console.log('facebook')
respondWithResult(output)
});
}
via Uma Maheshwaraa


No comments:
Post a Comment