worker.isDead()

worker.isDead() This function returns true if the worker's process has terminated (either because of exiting or being signaled). Otherwise, it returns false.

worker.isConnected()

worker.isConnected() This function returns true if the worker is connected to its master via its IPC channel, false otherwise. A worker is connected to its master after it's been created. It is disconnected after the 'disconnect' event is emitted.

worker.id

worker.id <Number> Each new worker is given its own unique id, this id is stored in the id. While a worker is alive, this is the key that indexes it in cluster.workers

worker.disconnect()

worker.disconnect() In a worker, this function will close all servers, wait for the 'close' event on those servers, and then disconnect the IPC channel. In the master, an internal message is sent to the worker causing it to call .disconnect() on itself. Causes .suicide to be set. Note that after a server is closed, it will no longer accept new connections, but connections may be accepted by any other listening worker. Existing connections will be allowed to close as usual. When no more conne

Worker

Class: Worker A Worker object contains all public information and method about a worker. In the master it can be obtained using cluster.workers. In a worker it can be obtained using cluster.worker.

watcher.close()

watcher.close() Stop watching for changes on the given fs.FSWatcher.

vm.runInThisContext()

vm.runInThisContext(code[, options]) vm.runInThisContext() compiles code, runs it and returns the result. Running code does not have access to local scope, but does have access to the current global object. Example of using vm.runInThisContext() and eval() to run the same code: const vm = require('vm'); var localVar = 'initial value'; const vmResult = vm.runInThisContext('localVar = "vm";'); console.log('vmResult: ', vmResult); console.log('localVar: ', localVar); const evalResult = eval('l

vm.runInNewContext()

vm.runInNewContext(code[, sandbox][, options]) vm.runInNewContext() compiles code, contextifies sandbox if passed or creates a new contextified sandbox if it's omitted, and then runs the code with the sandbox as the global object and returns the result. vm.runInNewContext() takes the same options as vm.runInThisContext(). Example: compile and execute code that increments a global variable and sets a new one. These globals are contained in the sandbox. const util = require('util'); const vm =

vm.runInDebugContext()

vm.runInDebugContext(code) vm.runInDebugContext() compiles and executes code inside the V8 debug context. The primary use case is to get access to the V8 debug object: const Debug = vm.runInDebugContext('Debug'); Debug.scripts().forEach(function(script) { console.log(script.name); }); Note that the debug context and object are intrinsically tied to V8's debugger implementation and may change (or even get removed) without prior warning. The debug object can also be exposed with the --expose_de

vm.runInContext()

vm.runInContext(code, contextifiedSandbox[, options]) vm.runInContext() compiles code, then runs it in contextifiedSandbox and returns the result. Running code does not have access to local scope. The contextifiedSandbox object must have been previously contextified via vm.createContext(); it will be used as the global object for code. vm.runInContext() takes the same options as vm.runInThisContext(). Example: compile and execute different scripts in a single existing context. const util = r