Dump the server by issuing a "introspect" instruction to the server listener
436833
public ReturnCode introspectServer(String dumpTimestamp, Set<JavaDumpAction> javaDumpActions) {
        // Since "server dump" is used for diagnostics, we go out of our way to
        // not send an unrecognized command to the server even if the user has
        // broken their environment such that the client process supports java
        // dumps but the server doesn't.
        String command;
        if (javaDumpActions.isEmpty()) {
            command = INTROSPECT_COMMAND + DELIM + dumpTimestamp;
        } else {
            StringBuilder commandBuilder = new StringBuilder().append(INTROSPECT_JAVADUMP_COMMAND).append(DELIM).append(dumpTimestamp);
            for (JavaDumpAction javaDumpAction : javaDumpActions) {
                commandBuilder.append(',').append(javaDumpAction.name());
            }
            command = commandBuilder.toString();
        }

        return write(command,
                     ReturnCode.DUMP_ACTION,
                     ReturnCode.ERROR_SERVER_DUMP);
    }
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));
}
799420
@Override
   protected void dumpJFapServerStatus(IncidentStream is)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "dumpJFapServerStatus", is);
      
      is.writeLine("No Server Conversation Dump", "");
      
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "dumpJFapServerStatus");
   }
264747
def shutdown_server(self):
        """"""
        self.log.debug('shutdown_server: in')
        if self.ensime and self.toggle_teardown:
            self.ensime.stop()
1167484
def dumpdata(app_target, *args, **kwargs):
    """"""
    options = {
        '--indent': 4,
    }
    options.update(kwargs)

    # Quiet down pynt...
    logger = logging.getLogger('pynt')
    logger.propagate = False

    project.execute_manage('dumpdata', app_target, *args, **options)
988646
private void dumpMEtoMEConversations(final IncidentStream is) 
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "dumpMEtoMEConversations", is);
      
      final ServerConnectionManager scm = ServerConnectionManager.getRef();
      final List obc = scm.getActiveOutboundMEtoMEConversations();
      
      is.writeLine("", "");
      is.writeLine("\n------ ME to ME Conversation Dump ------ ", ">");
      
      if (obc != null)
      {
         //Build a map of connection -> conversation so that we can output the
         //connection information once per set of conversations.
         final Map<Object, LinkedList<Conversation>> connectionToConversationMap = convertToMap(is, obc);

         //Go through the map and dump out a connection - followed by its conversations
         for (final Iterator<Entry<Object,LinkedList<Conversation>>>i = connectionToConversationMap.entrySet().iterator(); i.hasNext();)
         {
            final Entry<Object, LinkedList<Conversation>>entry = i.next();
            is.writeLine("\nOutbound connection:", entry.getKey());

            final LinkedList conversationList = entry.getValue();
            while(!conversationList.isEmpty())
            {
               final Conversation c = (Conversation)conversationList.removeFirst();
               is.writeLine("\nOutbound Conversation[" + c.getId() + "]: ", c.getFullSummary());
               
               try
               {
                  dumpMEtoMEConversation(is, c);
               }
               catch(Throwable t)
               {
                  // No FFDC Code Needed
                  is.writeLine("\nUnable to dump conversation", t);
               }        
            }
         }
      }
      
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "dumpMEtoMEConversations");
   }
219601
def dump(self):
        """"""
        with self.lock:
            atexit.unregister(self.dump)
            self.fh.close()
730994
public void dump() {

        if (dumped) {
            return;
        }

        try {
            Tr.dump(tc, "-- StatefulBeanReaper Dump -- ", this);
            synchronized (this) {
                Tr.dump(tc, "Number of objects:      " + this.numObjects);
                Tr.dump(tc, "Number of adds:         " + this.numAdds);
                Tr.dump(tc, "Number of removes:      " + this.numRemoves);
                Tr.dump(tc, "Number of null removes: " + this.numNullRemoves);
                Tr.dump(tc, "Number of deletes:      " + this.numDeletes);
            }
        } finally {
            dumped = true;
        }
    }
562158
public void dump()
    {
        Object allData[] = new Object[] {
                                         this,
                                         "EJBName                     = " + ivEjbName,
                                         "method name                 = " + ivMethodName,
                                         "method parameters           = " + ivMethodParms,
                                         "binding style               = " + ivBindingStyle,
                                         "exclude default inteceptors = " + ivExcludeDefaultLevelInterceptors,
                                         "exclude class inteceptors   = " + ivExcludeClassLevelInterceptors,
        }; // d457352

        int totalLength = allData.length;

        String[] interceptorOrder = null;
        if (ivInterceptorOrder != null)
        {
            interceptorOrder = new String[ivInterceptorOrder.size()];
            interceptorOrder = ivInterceptorOrder.toArray(interceptorOrder);
            totalLength += interceptorOrder.length + 2;
        }

        String[] interceptorNames = null;
        if (ivInterceptorClassNames != null)
        {
            interceptorNames = new String[ivInterceptorClassNames.size()];
            interceptorNames = ivInterceptorClassNames.toArray(interceptorNames);
            totalLength += interceptorNames.length + 2;
        }

        int index = 0;
        Object dumpData[] = new Object[totalLength];
        System.arraycopy(allData, 0, dumpData, index, allData.length);
        index += allData.length;

        if (interceptorOrder != null)
        {
            dumpData[index++] = "Interceptor Order: ";
            dumpData[index++] = " ";
            System.arraycopy(interceptorOrder, 0, dumpData, index, interceptorOrder.length);
            index += interceptorOrder.length;
        }

        if (interceptorNames != null)
        {
            dumpData[index++] = "Interceptor Class Names: ";
            dumpData[index++] = " ";
            System.arraycopy(interceptorNames, 0, dumpData, index, interceptorNames.length);
            index += interceptorNames.length;
        }

        Tr.dump(tc, "-- EJBInterceptorBinding Dump --", dumpData);
        Tr.dump(tc, "-- EJBInterceptorBinding Dump End --");
    }
873572
void waitForExit()
  {
    Runtime runtime = Runtime.getRuntime();

    ShutdownSystem shutdown = _resinSystem.getSystem(ShutdownSystem.class);

    if (shutdown == null) {
      throw new IllegalStateException(L.l("'{0}' requires an active {1}",
                                          this,
                                          ShutdownSystem.class.getSimpleName()));
    }

    /*
     * If the server has a parent process watching over us, close
     * gracefully when the parent dies.
     */
    while (! _server.isClosing()) {
      try {
        Thread.sleep(10);

        if (! checkMemory(runtime)) {
          shutdown.shutdown(ShutdownModeAmp.IMMEDIATE,
                            ExitCode.MEMORY,
                            "Server shutdown from out of memory");
          // dumpHeapOnExit();
          return;
        }

        if (! checkFileDescriptor()) {
          shutdown.shutdown(ShutdownModeAmp.IMMEDIATE,
                            ExitCode.MEMORY,
                            "Server shutdown from out of file descriptors");
          //dumpHeapOnExit();
          return;
        }

        synchronized (this) {
          wait(10000);
        }
      } catch (OutOfMemoryError e) {
        String msg = "Server shutdown from out of memory";

        ShutdownSystem.shutdownOutOfMemory(msg);
      } catch (Throwable e) {
        log.log(Level.WARNING, e.toString(), e);

        return;
      }
    }
  }
494931
def on_close(self):
        '''
        
        '''

        if self.id in self.funcserver.websocks:
            self.funcserver.websocks[self.id] = None
            ioloop = tornado.ioloop.IOLoop.instance()
            ioloop.add_callback(lambda: self.funcserver.websocks.pop(self.id, None))

        psession = self.funcserver.pysessions.get(self.pysession_id, None)
        if psession:
            psession['socks'].remove(self.id)
            if not psession['socks']:
                del self.funcserver.pysessions[self.pysession_id]
1075773
def execute_quiet(command, error_message)
      # Ladies and gentleman: More debug, please!
      puts command if @debug
      return_value = -1

      Open3.popen3(environment, command) do |_stdin, stdout, stderr, wait_thread|
        Thread.new do
          stdout.each do |line|
            @last_output << line.strip
            puts line unless @quiet
          end
        end

        Thread.new do
          stderr.each do |line|
            @last_error << line
            puts line unless @quiet
          end
        end

        _stdin.close

        return_value = wait_thread.value

        if @strict and return_value.exitstatus != 0
          dump_error_message(command)
          fail error_message
        end
      end

      puts "Program exited with status #{return_value.exitstatus}." if @debug

      return_value.exitstatus == 0
    end
843640
public void dump(OutputStream out){
        hydrate();
        PrintWriter p = new PrintWriter(out);
        for(Model m : delegate){
            p.write(m.toString());
            p.write('\n');
        }
        p.flush();
    }
514931
def _dump(self, service, grep=None):
        
        if grep:
            return self.adb_shell('dumpsys {0} | grep "{1}"'.format(service, grep))
        return self.adb_shell('dumpsys {0}'.format(service))
1122645
public ReturnCode dump() {
        System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverDumping"), serverName));

        Set<JavaDumpAction> javaDumpActions = new LinkedHashSet<JavaDumpAction>();
        parseJavaDumpInclude(javaDumpActions);

        ServerDumpPackager sdp = new ServerDumpPackager(bootProps, launchArgs.getOption(BootstrapConstants.CLI_ARG_ARCHIVE_TARGET));
        sdp.initializeDumpDirectory();

        ReturnCode dumpRc = createDumps(javaDumpActions, true, sdp.getDumpTimestamp());

        boolean serverInactiveStatusFlag = dumpRc == ReturnCode.SERVER_INACTIVE_STATUS;
        boolean serverUnknownStatusFlag = dumpRc == ReturnCode.SERVER_UNKNOWN_STATUS;
        boolean serverCommandPortDisabledFlag = dumpRc == ReturnCode.SERVER_COMMAND_PORT_DISABLED_STATUS;

        if (dumpRc == ReturnCode.OK) {
            File dumpedFlag = new File(sdp.getDumpDir(), BootstrapConstants.SERVER_DUMPED_FLAG_FILE_NAME);
            if (!dumpedFlag.exists()) {
                dumpRc = ReturnCode.ERROR_SERVER_DUMP;
            }
        }

        // already dumped, then zip up. Dump zip must be created in the output directory
        if (dumpRc == ReturnCode.OK || dumpRc == ReturnCode.SERVER_INACTIVE_STATUS || dumpRc == ReturnCode.SERVER_UNKNOWN_STATUS
            || dumpRc == ReturnCode.SERVER_COMMAND_PORT_DISABLED_STATUS) {

            if (javaDumpActions != null && (!!!javaDumpActions.isEmpty())) {
                dumpRc = sdp.packageDump(true);
            } else {
                dumpRc = sdp.packageDump(false);
            }
        }

        sdp.cleanupDumpDirectory();

        if (dumpRc == ReturnCode.OK) {
            if (serverInactiveStatusFlag) {
                // We are dumping a stopped server. Since it is not a problem, just print a message.
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverNotRunning"), serverName));
            }
            if (serverUnknownStatusFlag) {
                // We tried to attach to the server process, but that failed.
                // Since it might indicate an error, print a message and change the return code though the dump archive has been generated successfully.
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverStatusException"), serverName));
                dumpRc = ReturnCode.SERVER_UNKNOWN_STATUS;
            }
            if (serverCommandPortDisabledFlag) {
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("warning.serverDumpCompleteCommandPortDisabled"), serverName,
                                                        sdp.getDumpFile().getAbsolutePath()));
            } else {
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverDumpComplete"), serverName, sdp.getDumpFile().getAbsolutePath()));
            }
        } else {
            System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverDumpException"), serverName));
        }

        return dumpRc;
    }
684163
def listen_init(self):
        """"""
        self.dispatcher = ObjectDispatch(self)
        self.factory = MsgPackProtocolFactory(self.dispatcher)
        self.server = UnixServer(self.loop, self.factory, self.path)
        self.server.start()
1374052
def main(argv=None):
    """"""
    #
    # `simpl server`
    #
    logging.basicConfig(level=logging.INFO)
    server_func = functools.partial(server.main, argv=argv)
    server_parser = server.attach_parser(default_subparser())
    server_parser.set_defaults(_func=server_func)

    # the following code shouldn't need to change when
    # we add a new subcommand.
    args = default_parser().parse_args(argv)
    args._func()