Launch or restart the Node.js server
342375
function runServer(cb) {
  function onStdOut(data) {
    const time = new Date().toTimeString();
    const match = data.toString('utf8').match(RUNNING_REGEXP);

    process.stdout.write(time.replace(/.*(\d{2}:\d{2}:\d{2}).*/, '[$1] '));
    process.stdout.write(data);

    if (match) {
      server.stdout.removeListener('data', onStdOut);
      server.stdout.on('data', x => process.stdout.write(x));
      if (cb) {
        cb(null, match[1]);
      }
    }
  }

  if (server) {
    server.kill('SIGTERM');
  }

  server = cp.spawn('node', [serverPath], {
    env: Object.assign({ NODE_ENV: 'development' }, process.env),
    silent: false,
  });

  server.stdout.on('data', onStdOut);
  server.stderr.on('data', x => process.stderr.write(x));
}
616778
def start_rest_server(port, platform, mode, config_file_name, experiment_id=None, log_dir=None, log_level=None):
    ''''''
    nni_config = Config(config_file_name)
    if detect_port(port):
        print_error('Port %s is used by another process, please reset the port!\n' \
        'You could use \'nnictl create --help\' to get help information' % port)
        exit(1)
    
    if (platform != 'local') and detect_port(int(port) + 1):
        print_error('PAI mode need an additional adjacent port %d, and the port %d is used by another process!\n' \
        'You could set another port to start experiment!\n' \
        'You could use \'nnictl create --help\' to get help information' % ((int(port) + 1), (int(port) + 1)))
        exit(1)

    print_normal('Starting restful server...')
    
    entry_dir = get_nni_installation_path()
    entry_file = os.path.join(entry_dir, 'main.js')
    
    node_command = 'node'
    if sys.platform == 'win32':
        node_command = os.path.join(entry_dir[:-3], 'Scripts', 'node.exe')
    cmds = [node_command, entry_file, '--port', str(port), '--mode', platform, '--start_mode', mode]
    if log_dir is not None:
        cmds += ['--log_dir', log_dir]
    if log_level is not None:
        cmds += ['--log_level', log_level]
    if mode == 'resume':
        cmds += ['--experiment_id', experiment_id]
    stdout_full_path, stderr_full_path = get_log_path(config_file_name)
    stdout_file = open(stdout_full_path, 'a+')
    stderr_file = open(stderr_full_path, 'a+')
    time_now = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
    #add time information in the header of log files
    log_header = LOG_HEADER % str(time_now)
    stdout_file.write(log_header)
    stderr_file.write(log_header)
    if sys.platform == 'win32':
        from subprocess import CREATE_NEW_PROCESS_GROUP
        process = Popen(cmds, cwd=entry_dir, stdout=stdout_file, stderr=stderr_file, creationflags=CREATE_NEW_PROCESS_GROUP)
    else:
        process = Popen(cmds, cwd=entry_dir, stdout=stdout_file, stderr=stderr_file)
    return process, str(time_now)
737565
def start_server(self):
        """"""
        if self.server is None:
            self.port = select_port(default_port=self.DEFAULT_PORT)
            self.set_home_url('http://localhost:%d/' % self.port)
        elif self.server.isRunning():
            self.server.server_started.disconnect(self.initialize_continued)
            self.server.quit()
        self.server = PydocServer(port=self.port)
        self.server.server_started.connect(self.initialize_continued)
        self.server.start()
1243681
function startServer() {
    http.createServer((req, res) => {
        const fileName = __dirname + path.sep + new Date().getTime() + '.png';

        req.on('end', () => {
            res.writeHead(200);
            res.end();

            fs.stat(fileName, function(error, stat) {
              console.log(
                'Stored file ' + fileName +
                ' with size ' + stat.size +
                ', headers: ' + JSON.stringify(req.headers)
              );
              fs.unlinkSync(fileName);
            });
        });
        req.pipe(fs.createWriteStream(fileName));
    }).listen(DEF_CLIENT_PORT);

    console.log("Client server running on port 8124");
}
226497
def generate_start_command(server, options_override=None, standalone=False):
    
    command = []

    if mongod_needs_numactl():
        log_info("Running on a NUMA machine...")
        command = apply_numactl(command)

    # append the mongod executable
    command.append(get_server_executable(server))

    # create the command args
    cmd_options = server.export_cmd_options(options_override=options_override,
                                            standalone=standalone)

    command.extend(options_to_command_args(cmd_options))
    return command
1052743
function run (config, done) {
  config = config || {}

  logger.setupFromConfig(config)

  done = helper.isFunction(done) ? done : process.exit
  config = cfg.parseConfig(config.configFile, config)

  let exitCode = 1
  const options = {
    hostname: config.hostname,
    path: config.urlRoot + 'run',
    port: config.port,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    }
  }

  const request = http.request(options, function (response) {
    response.on('data', function (buffer) {
      const parsedResult = parseExitCode(buffer, exitCode, config.failOnEmptyTestSuite)
      exitCode = parsedResult.exitCode
      process.stdout.write(parsedResult.buffer)
    })

    response.on('end', () => done(exitCode))
  })

  request.on('error', function (e) {
    if (e.code === 'ECONNREFUSED') {
      log.error('There is no server listening on port %d', options.port)
      done(1, e.code)
    } else {
      throw e
    }
  })

  request.end(JSON.stringify({
    args: config.clientArgs,
    removedFiles: config.removedFiles,
    changedFiles: config.changedFiles,
    addedFiles: config.addedFiles,
    refresh: config.refresh,
    colors: config.colors
  }))
}
316083
function run() {
  var bin = path.resolve(__dirname, '../node_modules/.bin/mocha');
  var args = Array.prototype.slice.call(arguments);
  var fn = args.pop();
  var cmd = [bin].concat(args).join(' ') + ' --no-colors';
  exec(cmd, fn);
}
467483
def StartExecServer():
  """"""
  sockdir = '/tmp/pyringe_%s' % os.getpid()
  if not os.path.isdir(sockdir):
    os.mkdir(sockdir)
  socket_path = ('%s/%s.execsock' %
                 (sockdir, threading.current_thread().ident))

  if os.path.exists(socket_path):
    os.remove(socket_path)

  exec_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
  exec_sock.bind(socket_path)
  exec_sock.listen(5)
  shutdown = False
  while not shutdown:
    conn, _ = exec_sock.accept()

    data = conn.recv(1024)
    if data:
      if data == '__kill__':
        shutdown = True
        conn.send('__kill_ack__')
        break
      data = json.loads(data)
      try:
        conn.sendall(json.dumps(eval(data)))
      except SyntaxError:
        # Okay, so it probably wasn't an expression
        try:
          exec data  # pylint: disable=exec-used
        except:  # pylint: disable=bare-except
          # Whatever goes wrong when exec'ing this, we don't want to crash.
          # TODO: think of a way to properly tunnel exceptions, if
          # possible without introducing more magic strings.
          pass
        finally:
          conn.sendall(json.dumps(None))
  exec_sock.shutdown(socket.SHUT_RDWR)
  exec_sock.close()
  os.remove(socket_path)
141607
function listen() {
	let httpServer = require('http').createServer(router);
	httpServer.listen(port);
	Coralian.logger.log("Server started");
}
31691
function start() {
      // Listen to the port
      app.listen(hrsConfigs.port, function (err) {
        if (err) {
          info(err);
        }
        info('Running on http://%s:%s', hrsConfigs.address, hrsConfigs.port);
      });
    }
700239
function restart() {
	logger.log('Restarting', clc.green(script));
	notifyWebSocket('restart');
	if (!kill(true)) {
		// The process wasn't running, start it now.
		start(true);
	} /*else {
		// The process will restart when its 'exit' event is emitted.
	}*/
}
1130938
function main() {
  var server = new grpc.Server();
  server.addService(services.GreeterService, {sayHello: sayHello});
  server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
  server.start();
}
907113
function main(args) {
  process.on("uncaughtException", onUncaughtException)

  var opts  = getOpts.parse(args).opts

  var webServer = http.createServer(onRequest)

  utils.log("version: " + utils.VERSION)
  utils.log("server starting")
  webServer.listen(opts.port, function() {
    utils.log("server started on http://localhost:" + opts.port)
  })

  var config = {
    httpServer: webServer
  }

  var rserver = ragentsServer.createServer(config)
  rserver.start()
}
742967
def runserver(app=None, reloader=None, debug=None, host=None, port=None):
    """"""
    debug = debug or app.config.get('DEBUG', False)
    reloader = reloader or app.config.get('RELOADER', False)
    host = host or app.config.get('HOST', '127.0.0.1')
    port = port or app.config.get('PORT', 5000)
    app.run(
        use_reloader=reloader,
        debug=debug,
        host=host,
        port=port
    )
78221
async function start() {
  try {
    await server.register({ plugin: hapijsStatusMonitor });
    await server.start();
  }
  catch (err) {
    console.log(err);
    process.exit(1);
  }

  console.log('Server running at:', server.info.uri);
}
949886
function startServer(alerts, params, port, resources) {
    const compiledAlerts = compileMarkdown(alerts);
    const app = http.createServer((req, res) =>
        res.end(resources[req.url] || resources['/index.html']));
    const io = listen(app);
    io.on('connection', socket => {
        emitInfo(`new session for ${socket.handshake.address}`);
        socket.emit('update', compiledAlerts);
        socket.on('disconnect', () => {
            emitInfo(`disconnected session ${socket.handshake.address}`);
        });
    });

    return new Promise(resolve => app.listen(port, emitRungEmoji & resolve))
        .then(~watchChanges(io, params));
}
679152
def run(self, host='localhost', port=1234):
        
        # Setup loop
        loop = asyncio.get_event_loop()
        coro = asyncio.start_server(self._handle, host, port, loop=loop)
        try:
            server = loop.run_until_complete(coro)
        except Exception as e:
            self._logger.error('Could not launch server: {}'.format(e))
            return

        # Run the server
        self._logger.info('Serving on {}'.format(server.sockets[0].getsockname()))
        try:
            loop.run_forever()
        except KeyboardInterrupt:
            pass

        # Close the server
        server.close()
        loop.run_until_complete(server.wait_closed())
        loop.close()