MCPcopy Index your code
hub / github.com/totaljs/framework / master

Function master

cluster.js:193–378  ·  view source on GitHub ↗
(count, mode, options, callback, https)

Source from the content-addressed store, hash-verified

191};
192
193function master(count, mode, options, callback, https) {
194
195 if (count == null)
196 count = require('os').cpus().length;
197
198 OPTIONS.auto = count === 'auto';
199
200 if (OPTIONS.auto)
201 count = 1;
202
203 if (typeof(options) === 'function') {
204 callback = options;
205 options = {};
206 } else if (!options)
207 options = {};
208
209 OPTIONS.count = count;
210 OPTIONS.mode = mode;
211 OPTIONS.options = options;
212
213 var Os = require('os');
214 require('./utils');
215
216 console.log('==================== CLUSTER =======================');
217 console.log('PID : ' + process.pid);
218 console.log('Node.js : ' + process.version);
219 console.log('OS : ' + Os.platform() + ' ' + Os.release());
220 console.log('Threads : {0}'.format(OPTIONS.auto ? 'auto' : (count + 'x')));
221 console.log('====================================================');
222 console.log('Date : ' + new Date().format('yyyy-MM-dd HH:mm:ss'));
223 console.log('Mode : ' + mode);
224 options.thread && console.log('Thread : ' + options.thread);
225 console.log('====================================================\n');
226
227 if (options.thread)
228 global.THREAD = options.thread;
229
230 if (mode === 'debug') {
231 require('./debug').watcher(function(changes) {
232 var can = false;
233 if (options.thread) {
234 for (var i = 0; i < changes.length; i++) {
235 var change = changes[i];
236 if (change.indexOf('/threads/') !== -1) {
237 if (change.indexOf('/threads/' + options.thread + '/') !== -1) {
238 can = true;
239 break;
240 }
241 } else {
242 can = true;
243 break;
244 }
245 }
246 } else
247 can = true;
248 can && exports.restart();
249 });
250 }

Callers 1

cluster.jsFile · 0.85

Calls 3

execFunction · 0.85
callbackFunction · 0.85
canFunction · 0.70

Tested by

no test coverage detected