title: How to execute / abort long running tasks in Node JS?
body: <p>NodeJS server with a Mongo DB - one feature will generate a report JSON file from the DB, which can take a while (60 seconds up - has to process hundreds of thousands of entries). </p>
  
  <p>We want to run this as a background task. We need to be able to start a report build process, monitor it, and abort it if the user decides to change the params and re build it.</p>
  
  <p>What is the simplest approach with node?  Don't really want to get into the realms of separate worker servers processing jobs, message queues etc - we need to keep this on the same box and fairly simple implementation.</p>
  
  <p>1) Start the build as a async method, and return to the user, with socket.io reporting progress? </p>
  
  <p>2) Spin off a child process for the build script?</p>
  
  <p>3) Use something like <a href="https://www.npmjs.com/package/webworker-threads">https://www.npmjs.com/package/webworker-threads</a>?</p>
  
  <p>With the few approaches I've looked at I get stuck on the same two areas;</p>
  
  <p>1) How to monitor progress? 
  2) How to abort an existing build process if the user re-submits data?</p>
  
  <p>Any pointers would be greatly appreciated...</p>