The master

@module
@author Kevin Smithson <ksmithson@sazze.com>
@author Craig Thayer <cthayer@sazze.com>
970991
function Master() {
  EventEmitter.call(this);

  if (config.workerMessageHandler) {
    this.workerMessageHandler = require(config.workerMessageHandler);
  }

  if (!_.isFunction(this.workerMessageHandler)) {
    this.workerMessageHandler = function () {};
  }

  this.workerMessageHandler.bind(this);
}
521174
function loadAndDescribeModuleInCwd() {
// Hack: Trick node into changing process.mainScript to moduleToDebug
  moduleToDebug = Module._load(location, module, true);

  var sample = getSampleCommand();
  sampleLine = util.format('You can access your module as `m`%s.', sample);

  prompt = getModuleName() + '> ';
}
891360
public void foundActiveMaster(Protocol newMasterProtocol) {
    if (isMasterHostFail()) {
      if (isExplicitClosed()) {
        newMasterProtocol.close();
        return;
      }
      if (!waitNewMasterProtocol.compareAndSet(null, newMasterProtocol)) {
        newMasterProtocol.close();
      }
    } else {
      newMasterProtocol.close();
    }

  }
337022
protected function _master()
    {
        if (null === $this->_master) {
            $this->_master = $this->_connection($this->_config_master);
        }
        return $this->_master;
    }
482120
public void postModule(final Module module, final String user, final String password) throws GrapesCommunicationException, AuthenticationException {
        final Client client = getClient(user, password);
        final WebResource resource = client.resource(serverURL).path(RequestUtils.moduleResourcePath());
        final ClientResponse response = resource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, module);

        client.destroy();
        if(ClientResponse.Status.CREATED.getStatusCode() != response.getStatus()){
            final String message = "Failed to POST module";
            if(LOG.isErrorEnabled()) {
                LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
            }
            throw new GrapesCommunicationException(message, response.getStatus());
        }
    }
687567
function optimizeModules () {
			grunt.log.write("Optimizing...");

			var mainModuleOverride = {
				// Specify a callback to be called for writing down app root modules content.
				// The callback wraps modules content into several nested 'require' calls (one for each layer modules)
				onBuildWrite: function (moduleName, modulePath, contents) {
					if (contents.indexOf("require(") < 0) { return contents; }
					if (modules.indexOf(moduleName) < 0) { return contents; }
					var start = "", end = "";
					layers.forEach(function (l) {
						start += "require([\"" + l.name + "\"], function () {\n";
						end += "\n});";
					});
					return contents.replace("require(", start + "require(") + end;
				}
			};
			function writeGenericCss (moduleName, modulePath, content) {
				grunt.verbose.writeln('Combining ' + moduleName + ' into ' + genericCssPath);
				var genericCssContent;
				if (file.exists(genericCssPath)) {
					genericCssContent = file.readFile(genericCssPath);
				}
				genericCssContent = genericCssContent ? genericCssContent + "\n" + content : content;
				file.saveFile(genericCssPath, genericCssContent);
				// remove original css
				file.deleteFile(modulePath);
			}
			// See https://github.com/jrburke/r.js/blob/master/build/example.build.js
			var config = lang.extend({}, requireConfig, {
				isOptimizeStage: true,
				optimize: options.optimizeJs,
				optimizeCss: options.optimizeCss,
				appDir: buildDir,
				dir: outputDir,
				baseUrl: "./",
				logLevel: 2, // WARN
				removeCombined: true,
				//skipDirOptimize: false,
				skipDirOptimize: true,
				keepBuildDir: false,
				locale: options.bundledLocale,
				preserveLicenseComments: options.preserveLicenseComments,
				generateSourceMaps: options.generateSourceMaps,
				writeGenericCss: writeGenericCss,
				// Custom parameter for xcss.js: path from 'generic.css' to baseDir
				genericCssToRootPath: genericCssToRootPath,
				// Pragmas for rjs plugins:
				pragmas: {
					optimize: true,
					build: true
				},
				pragmasOnSave: {
					optimizeSave: true
				},
				modules: [
					// here we'll combine layer modules and app root modules
				]
			});
			if (options.requireConfigOutput) {
				config = lang.extendEx(config, options.requireConfigOutput, {deep: true});
			}

			// Initialize config.modules - root modules to optimize
			// First we're adding "layer modules" (built on the previous step)
			var excludedLayers = options.ignoreModules;
			layers.forEach(function (l) {
				config.modules.push({
					name: l.name,
					exclude: excludedLayers.slice()
				});
				excludedLayers.push(l.name);
			});
			// then add root application modules (main.js and so on)
			modules.forEach(function (m) {
				config.modules.push({
					name: m,
					exclude: excludedLayers,
					override: mainModuleOverride
				});
			});
			// options for particular layers
			if (options.layerOverrides) {
				config.modules.forEach(function (layer) {
					var name = layer.name;
					var overrides = options.layerOverrides[name];
					if (overrides) {
						// convert task's format into rjs format:
						if (overrides.optimizeJs) {
							overrides.optimize = overrides.optimizeJs;
						}
						if (layer.override) {
							layer.override = lang.extendEx(layer.override, overrides, {deep: true});
						} else {
							layer.override = overrides;
						}
					}
				});
			}

			requirejs.optimize(
				config,
				lang.safeCallback(optimizeBootModules),
				lang.errorCallback
			);
		}
1204043
def logToMaster(self, text, level=logging.INFO):
        
        logger.log(level=level, msg=("LOG-TO-MASTER: " + text))
        self.loggingMessages.append(dict(text=text, level=level))
536407
function connect (master) {
    if (_socket && _socket._master.name === master.name) {
      debug(`already connected to master ${master.name}`)
      return
    }
    if (_connectingMaster && _connectingMaster.name === master.name) {
      debug(`already connecting to master ${master.name}`)
      return
    }

    _connectingMaster = master
    let newSocket = _getSocket(master)

    let _messagesToResend = []
    let _onMessagePublished = (...args) => {
      if (_socket) _messagesToResend.push(args)
    }
    _publishStream.on('message', _onMessagePublished)

    debug(`connecting to ${master.name} at ${master.endpoint}`)

    let connectionStart = Date.now()
    const onSocketConnected = timingoutCallback((err) => {
      _publishStream.removeListener('message', _onMessagePublished)
      newSocket.unmonitor()

      if (
        err ||
        !_connectingMaster ||
        _connectingMaster.name === !master.name
      ) {
        newSocket.close()
        if (err) {
          debug(`failed to connect to ${master.name} at ${master.endpoint}`)
          disconnect()
        }
        return
      }

      _connectingMaster = null
      let previousSocket = _socket

      debug(`${previousSocket ? 'switched' : 'connected'} to ${master.name} at ${master.endpoint} in ${Date.now() - connectionStart} ms`)

      _socket = newSocket

      let totalMessagesToResend = _messagesToResend.length
      if (totalMessagesToResend) {
        debug(`resending ${totalMessagesToResend} messages published while transitioning`)
        _messagesToResend.forEach(message => _socket.send(message))
      }

      if (previousSocket) {
        previousSocket.close()
        debug(`closed previous connection to ${previousSocket._master.name} at ${previousSocket._master.endpoint}`)
      } else {
        connection.emit('connect')
      }
    }, 500)

    newSocket.once('connect', () => onSocketConnected())
    return connection
  }
104177
function setupModule() {

    // Shims

    if(typeof self === 'undefined') {
      global.self = global;
    }

    if(!self.URL) {
      self.URL = self.webkitURL;
    }

    // Make sure are on https in browser,
    // otherwise crypto etc. wont work.

    if(isBrowser() &&
        self.location.protocol === 'http:' &&
        self.location.hostname !== 'localhost' &&
        !self.location.hostname.startsWith('192.168.')) {
      self.location.href = self.location.href.replace(/http/, 'https');
    }

    // Setup / export module

    da = self.direape || {};

    if(typeof module === 'undefined') {
      self.direape = da;
    } else {
      module.exports = da;
    }

    da.test = test;

    // Define name of testsuite

    testSuite('direape');
  }
557291
def set_master(self, url):
        """"""
        m = urlparse(url)
        self.master_scheme = m.scheme
        self.master_netloc = m.netloc
        self.master_path = os.path.dirname(m.path)
557995
function MasterNode(io, config, pass) {
  EventEmitter.call(this);
  this.connected = [];  // array of connected clients.
  this.disconnected = []; // an array of disconnected and removed clients.
  this.disconnecting = [];  //array of disconnecting clients (didn't reconnect within 10sec)
  this.io = io;
  this.config = config;
  this.config.password = crux.util.sha2(pass);
  this.__loadDump();
  this.bind();
}
266903
@Override
    protected Stream<Module> buildGuiceModules() {
        return Stream.concat(Stream.concat(
                    super.buildGuiceModules(),
                    sqlConfiguration.buildGuiceModules()),
                Stream.of(
                        new OntopMappingSQLModule(this),
                        new OntopMappingPostModule(getSettings())));
    }
748361
def modules
      modules = @modules.dup # in case the user pushes any on
      modules << @authentication_strategy
      modules << :db_password
      modules << :password_reset
      modules << :trackable  # needs configuration
      modules << :timeoutable if @timeout_in
      modules << :lifetimed if @max_session_lifetime
      modules << :brute_force if @max_consecutive_bad_logins_allowed
      modules
    end
1101209
public static void main(String[] args) {
    if (!parseInputArgs(args)) {
      usage();
      System.exit(EXIT_FAILED);
    }
    if (sHelp) {
      usage();
      System.exit(EXIT_SUCCEEDED);
    }

    List<String> masters = new ArrayList<>();
    for (MasterFactory factory : ServiceUtils.getMasterServiceLoader()) {
      masters.add(factory.getName());
    }

    for (String master : masters) {
      Upgrader upgrader = new Upgrader(master,
          new InstancedConfiguration(ConfigurationUtils.defaults()));
      try {
        upgrader.upgrade();
      } catch (IOException e) {
        LOG.error("Failed to upgrade the journal for {}.", master, e);
        System.exit(EXIT_FAILED);
      }
    }
  }
406601
def load_commands
      @module = @module ? Util.constantize(@module) :
        Util.create_module(Boson::Commands, clean_name)
      before_load_commands
      check_for_method_conflicts unless @force
      actual_load_commands
    rescue MethodConflictError => err
      handle_method_conflict_error err
    end
1096390
public function showCommandList(): void
    {
        /** @var \Inhere\Console\IO\Input $input */
        $input = $this->input;
        // has option: --auto-completion
        $autoComp = $input->getBoolOpt('auto-completion');
        // has option: --shell-env
        $shellEnv = (string)$input->getLongOpt('shell-env', '');

        // php bin/app list --only-name
        if ($autoComp && $shellEnv === 'bash') {
            $this->dumpAutoCompletion($shellEnv, []);
            return;
        }

        /** @var \Inhere\Console\IO\Output $output */
        $output = $this->output;
        /** @var Router $router */
        $router = $this->getRouter();
        $script = $this->getScriptName();

        $hasGroup    = $hasCommand = false;
        $groupArr    = $commandArr = [];
        $placeholder = 'No description of the command';

        // all console groups/controllers
        if ($groups = $router->getControllers()) {
            $hasGroup = true;
            \ksort($groups);
        }

        // all independent commands, Independent, Single, Alone
        if ($commands = $router->getCommands()) {
            $hasCommand = true;
            \ksort($commands);
        }

        // add split title on both exists.
        if (!$autoComp && $hasCommand && $hasGroup) {
            $groupArr[]   = \PHP_EOL . '- <bold>Group Commands</bold>';
            $commandArr[] = \PHP_EOL . '- <bold>Alone Commands</bold>';
        }

        foreach ($groups as $name => $info) {
            $options    = $info['options'];
            $controller = $info['handler'];
            /** @var \Inhere\Console\AbstractHandler $controller */
            $desc    = $controller::getDescription() ?: $placeholder;
            $aliases = $options['aliases'];
            $extra   = $aliases ? ColorTag::wrap(
                ' [alias: ' . \implode(',', $aliases) . ']',
                'info'
            ) : '';

            // collect
            $groupArr[$name] = $desc . $extra;
        }

        if (!$hasGroup && $this->isDebug()) {
            $groupArr[] = '... Not register any group command(controller)';
        }

        foreach ($commands as $name => $info) {
            $desc    = $placeholder;
            $options = $info['options'];
            $command = $info['handler'];

            /** @var \Inhere\Console\AbstractHandler $command */
            if (\is_subclass_of($command, CommandInterface::class)) {
                $desc = $command::getDescription() ?: $placeholder;
            } elseif ($msg = $options['description'] ?? '') {
                $desc = $msg;
            } elseif (\is_string($command)) {
                $desc = 'A handler : ' . $command;
            } elseif (\is_object($command)) {
                $desc = 'A handler by ' . \get_class($command);
            }

            $aliases = $options['aliases'];
            $extra   = $aliases ? ColorTag::wrap(' [alias: ' . \implode(',', $aliases) . ']', 'info') : '';

            $commandArr[$name] = $desc . $extra;
        }

        if (!$hasCommand && $this->isDebug()) {
            $commandArr[] = '... Not register any alone command';
        }

        // built in commands
        $internalCommands = static::$internalCommands;

        if ($autoComp && $shellEnv === 'zsh') {
            $map = \array_merge($internalCommands, $groupArr, $commandArr);
            $this->dumpAutoCompletion('zsh', $map);
            return;
        }

        \ksort($internalCommands);
        Console::startBuffer();

        if ($appDesc = $this->getParam('description', '')) {
            $appVer = $this->getParam('version', '');
            Console::writeln(\sprintf('%s%s' . \PHP_EOL, $appDesc, $appVer ? " (Version: <info>$appVer</info>)" : ''));
        }

        // built in options
        $internalOptions = FormatUtil::alignOptions(self::$globalOptions);

        Show::mList([
            'Usage:'              => "$script <info>{command}</info> [--opt -v -h ...] [arg0 arg1 arg2=value2 ...]",
            'Options:'            => $internalOptions,
            'Internal Commands:'  => $internalCommands,
            'Available Commands:' => \array_merge($groupArr, $commandArr),
        ], [
            'sepChar' => '  ',
        ]);

        unset($groupArr, $commandArr, $internalCommands);
        Console::write("More command information, please use: <cyan>$script {command} -h</cyan>");
        Console::flushBuffer();
    }
1373852
@Beta
    // TODO maybe load with PELoader
    public MSDOSLoadModule readMSDOSLoadModule() throws IOException {
        MSDOSLoadModule module = new MSDOSLoadModule(msdos, file);
        module.read();
        return module;
    }