I periodically change the code in my production server. I have the following cluster code that allows workers to access my main Makes for
var cluster = essential ('cluster'); Starting function () {var worker = cluster.fork (); Console.log ('cluster: worker% d start', worker.id); } If (cluster.isMaster) {Required ('OS'). Cpus () ForEach (function () {startWorker ();}); // Log in to any worker who logs in; If a worker is disconnected, then he should get out, so we will wait for the exit incident // New worker to change this to a cluster. ('Disconnect', function (worker) {console.log ('CLUSTER: worker disconnected from cluster% d'., Worker.id);}); // When a worker dies (exit), create a worker to replace the cluster. ('Exit', function (worker, code, signal) {console.log ('cluster: exit code% d% of% d% s)', worker.id, code, signal); StartWorker ();}); } Launch our app on Else {// Worker; Meadowlark.js is required (see './ap.js') (); }
shows how to listen to a signal (SIGUSR2 in the case of the article, to restart workers) In short, it does something like this:
< Pre> process.on ("SIGUSR2", function ()} {// code to disconnect worker, delete cache and restart workers});
My question is: - Is the best way to signal the CigarsR2 process that it should reload workers? What if I have to send some additional information? - Who is sending the signal? Is this some OS feature that you can set to view files or directories? How can I go about doing this?
Note: - I would like to use some OS level feature which is not related to node.js. For example, some posts suggest using nodes.js specific modules like "not" etc., but I would not like to use "zero" :)
The Linux kernel file system supports the notification subsystem that is called. You can use it with nodes:
No comments:
Post a Comment