Datawheel / canon-stats

Reusable statistical and complexity calculations using NodeJS and Express
1 stars 1 forks source link

changes spawnSync back to spawn and adds more reliable timeout #22

Closed alexandersimoes closed 4 years ago

alexandersimoes commented 4 years ago

Hi @cnavarreteliz, these changes are based on work I did for the OEC and it seems like Spawn works better than Spawnsync. Also, unfortunately you cannot set a timeout with either Spawn or Spawnsync (as part of the childprocess api) so you have to use a JS settimeout.

The other important thing is to set {detached: true} as a configuration option to each spawned processes. This is necessary when a script that is called opens many different processes which all need to be killed when the timeout is reached.

Take a look at the code changes and see what you think.

cnavarreteliz commented 4 years ago

@alexandersimoes can you change api/baseRoute.js instead of src/api/baseRoute.js ?

alexandersimoes commented 4 years ago

Sure! I can make the change right now. Just for future reference, what is the difference of these 2 routes?