node.js - Communicating with a background task in node -
node.js - Communicating with a background task in node -
i have task running in background (downloading big file somewhere).
i need client able create http request , wait till status of task gets updated (for example, when percent completion of download changes).
right i'm using hack - i'm using require() singleton keeps track of background downloads, , background downloads store promises resolved when status changes, request can downloads[id].promise.then(res.json.bind(res)).
is there way without global singleton, without using external service redis pubsub?
@jonathanr, you're question pretty vague on accounts, might able started. if provide more info i'm sure help out. (what's process? simplified code snippet of now?)
i'm not sure if you're familiar child processes, should allow want. can run command can phone call shell (if utilize one), spinning other node programs/processes. lots of options, lots learn, super useful.
why think work in situation main process spawn kid process manage download. kid process can send messages updating main process when needs know something.
here's illustration in docs might relevant. cheers!
node.js background-process
Comments
Post a Comment