(count, mode, options, callback, https)
| 191 | }; |
| 192 | |
| 193 | function 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 | } |
no test coverage detected