Friday, 14 April 2017

Start background process in node (loopback)

I am trying to start a process in loopback which "archives" a part of the database every 5 minutes. Right now I am starting the archiver from a bootscript an schedule it every 5 minutes via setInterval:

// boot/start_archiver.js

setInterval(function(){
  console.log("Starting the Archiver");
  building_archiver.archiveBuildings();
  room_archiver.archiveRooms();
}, 300000);     // Archive every 5 minutes

I have a feeling that this is not the correct way of doing this, as it seems like the loopback API is unresponsive whenever the archiver runs.

How can I outsource the archiver call to a different process which runs separate from the API? Can you point me in the right direction or help me find a good framework?



via Biffy

No comments:

Post a Comment