Start GeoServer with GeoNode extensions
775349
def start_geoserver(options):
    
    from geonode.settings import INSTALLED_APPS, OGC_SERVER
    # only start if using Geoserver backend
    _backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
    if (_backend == 'geonode.qgis_server'
            or 'geonode.geoserver' not in INSTALLED_APPS):
        return

    GEOSERVER_BASE_URL = OGC_SERVER['default']['LOCATION']
    url = GEOSERVER_BASE_URL

    if urlparse(GEOSERVER_BASE_URL).hostname != 'localhost':
        print "Warning: OGC_SERVER['default']['LOCATION'] hostname is not equal to 'localhost'"

    if not GEOSERVER_BASE_URL.endswith('/'):
        print "Error: OGC_SERVER['default']['LOCATION'] does not end with a '/'"
        sys.exit(1)

    download_dir = path('downloaded').abspath()
    jetty_runner = download_dir / \
        os.path.basename(dev_config['JETTY_RUNNER_URL'])
    data_dir = path('geoserver/data').abspath()
    geofence_dir = path('geoserver/data/geofence').abspath()
    web_app = path('geoserver/geoserver').abspath()
    log_file = path('geoserver/jetty.log').abspath()
    config = path('scripts/misc/jetty-runner.xml').abspath()
    jetty_port = urlparse(GEOSERVER_BASE_URL).port

    import socket
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    socket_free = True
    try:
        s.bind(("127.0.0.1", jetty_port))
    except socket.error as e:
        socket_free = False
        if e.errno == 98:
            info('Port %s is already in use' % jetty_port)
        else:
            info(
                'Something else raised the socket.error exception while checking port %s'
                % jetty_port)
            print(e)
    finally:
        s.close()

    if socket_free:
        # @todo - we should not have set workdir to the datadir but a bug in geoserver
        # prevents geonode security from initializing correctly otherwise
        with pushd(data_dir):
            javapath = "java"
            loggernullpath = os.devnull

            # checking if our loggernullpath exists and if not, reset it to
            # something manageable
            if loggernullpath == "nul":
                try:
                    open("../../downloaded/null.txt", 'w+').close()
                except IOError as e:
                    print "Chances are that you have Geoserver currently running.  You \
                            can either stop all servers with paver stop or start only \
                            the django application with paver start_django."

                    sys.exit(1)
                loggernullpath = "../../downloaded/null.txt"

            try:
                sh(('java -version'))
            except BaseException:
                print "Java was not found in your path.  Trying some other options: "
                javapath_opt = None
                if os.environ.get('JAVA_HOME', None):
                    print "Using the JAVA_HOME environment variable"
                    javapath_opt = os.path.join(
                        os.path.abspath(os.environ['JAVA_HOME']), "bin",
                        "java.exe")
                elif options.get('java_path'):
                    javapath_opt = options.get('java_path')
                else:
                    print "Paver cannot find java in the Windows Environment.  \
                    Please provide the --java_path flag with your full path to \
                    java.exe e.g. --java_path=C:/path/to/java/bin/java.exe"

                    sys.exit(1)
                # if there are spaces
                javapath = 'START /B "" "' + javapath_opt + '"'

            sh((
                '%(javapath)s -Xms512m -Xmx2048m -server -XX:+UseConcMarkSweepGC -XX:MaxPermSize=512m'
                ' -DGEOSERVER_DATA_DIR=%(data_dir)s'
                ' -Dgeofence.dir=%(geofence_dir)s'
                # ' -Dgeofence-ovr=geofence-datasource-ovr.properties'
                # workaround for JAI sealed jar issue and jetty classloader
                # ' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true'
                ' -jar %(jetty_runner)s'
                ' --port %(jetty_port)i'
                ' --log %(log_file)s'
                ' %(config)s'
                ' > %(loggernullpath)s &' % locals()))

        info('Starting GeoServer on %s' % url)

    # wait for GeoServer to start
    started = waitfor(url)
    info('The logs are available at %s' % log_file)

    if not started:
        # If applications did not start in time we will give the user a chance
        # to inspect them and stop them manually.
        info(('GeoServer never started properly or timed out.'
              'It may still be running in the background.'))
        sys.exit(1)
47989
def startserver(self, hostname="localhost", port=8080,
                    daemon=False, handle_sigint=True):
        """"""
        if daemon:
            print("Sorry daemon server not supported just yet.")
            # TODO start as daemon similar to bitcoind
        else:
            print("Starting %s json-rpc service at http://%s:%s" % (
                self.__class__.__name__, hostname, port
            ))
            self._http_server = HTTPServer(
                server_address=(hostname, int(port)),
                RequestHandlerClass=self.get_http_request_handler()
            )

            if handle_sigint:
                def sigint_handler(signum, frame):
                    self._post_shutdown()
                    sys.exit(0)
                signal.signal(signal.SIGINT, sigint_handler)
            self._http_server.serve_forever()
730576
function modalDialog_start(aCallback) {
    if (!aCallback)
      throw new Error(arguments.callee.name + ": Callback not specified.");

    this._observer = new mdObserver(this._window, aCallback);

    this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
    this._timer.init(this._observer, DELAY_CHECK, Ci.nsITimer.TYPE_ONE_SHOT);
  }
893919
protected function bootExtension()
    {
        foreach ($this->extensionHandles() as $evt) {
            $this->server->registerEvent($evt['event'], $evt['handler']);
        }
    }
239784
function createServers(conf) {
  var seenKeys = map.create();

  var servers = _.map(conf.search('server'), function(serverNode) {
    var listenNode = serverNode.getOne('listen');
    if (!listenNode)
      throwForNode(serverNode,
          new Error('Required "listen" directive is missing'));

    var port = serverNode.getValues('listen').port;
    if (typeof port === 'undefined')
      port = 80;
    if (port <= 0)
      throwForNode(listenNode, new Error('Invalid port number'));

    var host = serverNode.getValues('listen').host || '::';
    if (host === '*')
      host = '::';

    if (!iputil.isValid(host)) {
      throwForNode(listenNode,
          new Error('Invalid IP address "' + host + '"'));
    }

    if (iputil.hasZone(host)) {
      throwForNode(listenNode,
          new Error(`Invalid IP address "${host}"--zone IDs are not currently supported`))
    }

    var serverNames = serverNode.getValues('server_name').names;

    // Read all locations. Use post-order traversal so that nested locs
    // get priority over their parents.
    var locations = _.chain(serverNode.search('location', false, true))
    .map(createLocation)
    .compact()
    .value();

    // We get the templateDir at the server level so that a global or server-
    // wide templateDir can be attached to the request directly. We may need
    // this if a page gets returns without a matching AppSpec (like a 404).
    var templateDir = serverNode.getValues('template_dir').dir;

    _.each(serverNames || [''], function(serverName) {
      var key = host + ':' + port;
      if (serverName !== '')
        key += '(' + serverName + ')';
      if (seenKeys[key])
        throwForNode(listenNode,
            new Error(key + ' combination conflicts with earlier server definition'));
      seenKeys[key] = true;
    });

    return new ServerRouter(port, host, serverNames, locations, templateDir);
  });

  return servers;
}
212314
function nodeDomainInitialized(reset) {
        initState()
            .done(function () {
                var inProgress = updateJsonHandler.get(updateProgressKey);
                if (inProgress && reset) {
                    setUpdateStateInJSON(updateProgressKey, !reset)
                        .always(checkUpdateStatus);
                 } else if (!inProgress) {
                    checkUpdateStatus();
                }
            });
    }
927169
private void startElementRootNode(final Attributes attributes) {

        LOG.debug("Found rootNode");
        try {
            this.rootNode = this.newNode(null, attributes);
            this.nodeStack.push(this.rootNode);
        } catch (final RepositoryException e) {
            throw new AssertionError("Could not create node", e);
        }
    }
1059125
function startupExtension(done) {
            if (self.closed) return done(null);

            self.extension = new Extension(options, done);
            self.extension.on('error', handlers.relayError);
        }
891481
def _startProgramsNode(self, name, attrs):
        """"""

        if name == 'program':
            self._programId = attrs.get('id')
            self._series = None
            self._title = None
            self._subtitle = None
            self._description = None
            self._mpaaRating = None
            self._starRating = None
            self._runTime = None
            self._year = None
            self._showType = None
            self._colorCode = None
            self._originalAirDate = None
            self._syndicatedEpisodeNumber = None
            self._advisories = []
716477
public void start() throws IOException {
    this.server.start();
    LOG.info("HdfsProxy server up at: " + sslAddr.getHostName() + ":"
        + sslAddr.getPort());
  }
295438
function populateMaps (extensions, types) {
  // source preference (least -> most)
  var preference = ['nginx', 'apache', undefined, 'iana']

  Object.keys(db).forEach(function forEachMimeType (type) {
    var mime = db[type]
    var exts = mime.extensions

    if (!exts || !exts.length) {
      return
    }

    // mime -> extensions
    extensions[type] = exts

    // extension -> mime
    for (var i = 0; i < exts.length; i++) {
      var extension = exts[i]

      if (types[extension]) {
        var from = preference.indexOf(db[types[extension]].source)
        var to = preference.indexOf(mime.source)

        if (types[extension] !== 'application/octet-stream' &&
          (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
          // skip the remapping
          continue
        }
      }

      // set the extension -> mime
      types[extension] = type
    }
  })
}
495065
function startBrowserSync(serverRoot) {

    console.log('Starting BrowserSync on port ' + 8010 + ' for ' + serverRoot);

    var options = {
        //proxy: 'localhost:' + port,
        port: 8010,
        ws: true,
        server: {
            baseDir: serverRoot
        },
        reloadDelay: 2000
    };

    browserSync.init(options);

}
1089418
function (start, end) {
            var ret = null, l;
            l = end - start;
            if (l > 0) {
                ret = this.nodeFactory.createCDataNode(this.page, start, end);
            }
            return ret;
        }
691734
def _startStationsNode(self, name, attrs):
        """"""

        if name == 'station':
            self._stationId = attrs.get('id')
            self._callSign = None
            self._stationName = None
            self._affiliate = None
            self._fccChannelNumber = None
354277
private static void startLocalNode() {
    // Figure self out; this is surprisingly hard
    NetworkInit.initializeNetworkSockets();

    // Do not forget to put SELF into the static configuration (to simulate proper multicast behavior)
    if ( !ARGS.client && H2O.isFlatfileEnabled() && !H2O.isNodeInFlatfile(SELF)) {
      Log.warn("Flatfile configuration does not include self: " + SELF + ", but contains " + H2O.getFlatfile());
      H2O.addNodeToFlatfile(SELF);
    }

    Log.info("H2O cloud name: '" + ARGS.name + "' on " + SELF +
            (H2O.isFlatfileEnabled()
                    ? (", discovery address " + CLOUD_MULTICAST_GROUP + ":" + CLOUD_MULTICAST_PORT)
                    : ", static configuration based on -flatfile " + ARGS.flatfile));

    if (!H2O.ARGS.disable_web) {
      Log.info("If you have trouble connecting, try SSH tunneling from your local machine (e.g., via port 55555):\n" +
              "  1. Open a terminal and run 'ssh -L 55555:localhost:"
              + API_PORT + " " + System.getProperty("user.name") + "@" + SELF_ADDRESS.getHostAddress() + "'\n" +
              "  2. Point your browser to " + NetworkInit.h2oHttpView.getScheme() + "://localhost:55555");
    }

    // Create the starter Cloud with 1 member
    SELF._heartbeat._jar_md5 = JarHash.JARHASH;
    SELF._heartbeat._client = ARGS.client;
    SELF._heartbeat._cloud_name_hash = ARGS.name.hashCode();
  }
341731
function createNodeServer(http, nodePort, webSocketPort, watchFiles, tsWarning, tsError, target) {
    return http.createServer(async (req, res) => {
        try {
            const fileExtension = req.url.slice(req.url.lastIndexOf('.') + 1);
            switch (fileExtension) {
                case '/': {
                    const indexFileContents = (await fs.readFile(`./index.html`)).toString();
                    const modifiedIndexFileContents = modifyHTML(indexFileContents, 'index.html', watchFiles, webSocketPort);
                    watchFile(`./index.html`, watchFiles);
                    res.end(modifiedIndexFileContents);
                    return;
                }
                case 'js': {
                    await handleScriptExtension(req, res, fileExtension);
                    return;
                }
                case 'mjs': {
                    await handleScriptExtension(req, res, fileExtension);
                    return;
                }
                case 'ts': {
                    await handleScriptExtension(req, res, fileExtension);
                    return;
                }
                case 'tsx': {
                    await handleScriptExtension(req, res, fileExtension);
                    return;
                }
                case 'jsx': {
                    await handleScriptExtension(req, res, fileExtension);
                    return;
                }
                case 'wast': {
                    await handleWASTExtension(req, res, fileExtension);
                    return;
                }
                case 'wasm': {
                    await handleWASMExtension(req, res, fileExtension);
                    return;
                }
                default: {
                    await handleGenericFile(req, res, fileExtension);
                    return;
                }
            }
        }
        catch(error) {
            console.log(error);
        }
    });
}
821779
public static void fill(Mapping src, Mapping dst) {
        for (Node off : src.getOfflineNodes()) {
            dst.addOfflineNode(off);
        }
        for (VM r : src.getReadyVMs()) {
            dst.addReadyVM(r);
        }
        for (Node on : src.getOnlineNodes()) {
            dst.addOnlineNode(on);
            for (VM r : src.getRunningVMs(on)) {
                dst.addRunningVM(r, on);
            }
            for (VM s : src.getSleepingVMs(on)) {
                dst.addSleepingVM(s, on);
            }

        }
    }