Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. request.get({ url: blogUrl }, function (err, res, blogFeedPage) {
  2. if (err) return next({ status: 502, message: 'error while trying to contact the blog feed server' })
  3.  
  4. var child = childProcess.fork(__dirname + '/child.js')
  5.  
  6. child.on('message', function (blogFeeds) {
  7. child.kill()
  8. if (!blogFeeds || blogFeeds && blogFeeds.error) {
  9. return next({ status: 503, message: 'Error while trying to parse the blog feed' })
  10. }
  11. clientRes.sendSuccess(200, 'success', blogFeeds)
  12. res.status(200).send({ status: 'success', data: blogFeeds })
  13. })
  14.  
  15. child.on('exit', function (code, signal) {
  16.  
  17. child.kill()
  18. })
  19.  
  20. child.on('error', function (error) {
  21. child.kill()
  22. })
  23.  
  24. child.send({ html: blogFeedPage })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement