Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
163
rated 0 times [  170] [ 7]  / answers: 1 / hits: 22215  / 12 Years ago, tue, february 12, 2013, 12:00:00

It seems like all the node woker processes are working as if it is executing a new copy of the same application. But would like to keep some variables that are shared by all node workers (child processes) in node cluster. Is there a simple way to do this?


More From » node.js

 Answers
90

All worker processes are indeed new copies of your application. Each worker is a full featured process created with child_process.spawn.
So no, they don't share variables. And it's probably best this way.
If you want to share information between worker processes (typically sessions) you should look into storing these information in a database.



If you're ready to go node all the way, you could use something like dnode to have your workers ask the master process for data.


[#80277] Monday, February 11, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rayvenc

Total Points: 666
Total Questions: 125
Total Answers: 99

Location: Northern Ireland
Member since Mon, Nov 14, 2022
2 Years ago
rayvenc questions
Tue, Apr 21, 20, 00:00, 4 Years ago
Mon, Apr 13, 20, 00:00, 4 Years ago
Sun, Mar 1, 20, 00:00, 4 Years ago
;