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.kill()

worker.kill([signal='SIGTERM']) signal <String> Name of the kill signal to send to the worker process. This function will kill the worker. In the master, it does this by disconnecting the worker.process, and once disconnected, killing with signal. In the worker, it does it by disconnecting the channel, and then exiting with code 0. Causes .suicide to be set. This method is aliased as worker.destroy() for backwards compatibility. Note that in a worker, process.kill() exists, but it i

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.

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

watcher.close()

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

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

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.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

vm.isContext()

vm.isContext(sandbox) Returns whether or not a sandbox object has been contextified by calling vm.createContext() on it.