public static void main(String[] args) throws UnknownHostException { for (String arg : args) { if (!( ADDRESS_REGEXP.matcher(arg).matches() || PORT_REGEXP.matcher(arg).matches() || ADDRESSPORT_REGEXP.matcher(arg).matches())) { throw new RuntimeException("JRuby's Nailgun server can only receive arguments via -X or -J-D properties."); } } NGServer.main(args); } }
public void run() { int count = 0; server.shutdown(false); // give the server up to five seconds to stop. is that enough? // remember that the shutdown will call nailShutdown in any // nails as well while (server.isRunning() && (count < 50)) { try { Thread.sleep(100); } catch (InterruptedException e) { } ++count; } if (server.isRunning()) { System.err.println("Unable to cleanly shutdown server. Exiting JVM Anyway."); } else { System.out.println("NGServer shut down."); } } }
private static void dumpStats(NGServer server, java.io.PrintStream out) { Map stats = server.getNailStats(); for (Iterator i = stats.values().iterator(); i.hasNext();) { out.println(i.next()); } }
usage(); return; NGServer server = new NGServer(serverAddress, port, DEFAULT_SESSIONPOOLSIZE); Thread t = new Thread(server); t.setName("NGServer(" + serverAddress + ", " + port + ")"); int runningPort = server.getPort(); while (runningPort == 0) { try { } catch (Throwable toIgnore) { runningPort = server.getPort();
Alias alias = server.getAliasManager().getAlias(command); Class cmdclass = null; if (alias != null) { cmdclass = alias.getAliasedClass(); } else if (server.allowsNailsByClassName()) { cmdclass = Class.forName(command); } else { cmdclass = server.getDefaultNailClass(); server.nailStarted(cmdclass); NGSecurityManager.setExit(exit); throw (t); } finally { server.nailFinished(cmdclass);
socket.delete(); server = new NGServer(new NGListeningAddress(socket.getAbsolutePath()), 10, 10000); } else { server = new NGServer(InetAddress.getLoopbackAddress(), options.port); System.out.println("K server started using IPC at " + dir.getAbsolutePath()); } else { int runningPort = server.getPort(); while (runningPort == 0) { try { } catch (InterruptedException e) { runningPort = server.getPort();
public static void nailMain(NGContext context) { context.getNGServer().shutdown(true); }
for (Iterator i = getAliasManager().getAliases().iterator(); i.hasNext();) { Alias alias = (Alias) i.next(); getOrCreateStatsFor(alias.getAliasedClass());
/** * Creates a new NGServer that will listen on the default port (defined in * <code>NGConstants.DEFAULT_PORT</code>). This does <b>not</b> cause the * server to start listening. To do so, create a new * <code>Thread</code> wrapping this * <code>NGServer</code> and start it. */ public NGServer() { init(null, NGConstants.DEFAULT_PORT, DEFAULT_SESSIONPOOLSIZE); }
/** * Provides a means for an NGSession to register the starting of a nail * execution with the server. * * @param nailClass the nail class that was launched */ void nailStarted(Class nailClass) { NailStats stats = getOrCreateStatsFor(nailClass); stats.nailStarted(); }
public static void nailMain(NGContext context) throws ClassNotFoundException { String[] args = context.getArgs(); NGServer server = context.getNGServer(); if (args.length == 0) { Set aliases = server.getAliasManager().getAliases(); // let's pad this nicely. first, find the longest alias // name. then pad the others to that width. int maxAliasLength = 0; int maxClassnameLength = 0; for (Iterator i = aliases.iterator(); i.hasNext();) { Alias alias = (Alias) i.next(); maxAliasLength = Math.max(maxAliasLength, alias.getName().length()); maxClassnameLength = Math.max(maxClassnameLength, alias.getAliasedClass().getName().length()); } for (Iterator i = aliases.iterator(); i.hasNext();) { Alias alias = (Alias) i.next(); context.out.println(padl(alias.getName(), maxAliasLength) + "\t" + padl(alias.getAliasedClass().getName(), maxClassnameLength)); context.out.println(padl("", maxAliasLength) + "\t" + alias.getDescription()); context.out.println(); } } else if (args.length == 2) { server.getAliasManager().addAlias(new Alias(args[0], "", Class.forName(args[1]))); } } }
public static void nailMain(NGContext context) { KServerFrontEnd kserver = KServerFrontEnd.instance(); if (!kserver.isLocal()) { context.assertLoopbackClient(); } if (context.getArgs()[0].equals("shutdown")) { System.setSecurityManager(null); context.getNGServer().shutdown(true); } else if (context.getArgs()[0].equals("reset")) { kserver.lock.writeLock().lock(); try { kserver.injectors.clear(); for (String tool : tools) { kserver.injectors.put(tool, Main.getInjector(tool)); } } finally { kserver.lock.writeLock().unlock(); } System.gc(); } }
/** * Creates a new NGServer that will listen at the specified address and on * the specified port with the specified session pool size. This does * <b>not</b> cause the server to start listening. To do so, create a new * <code>Thread</code> wrapping this * <code>NGServer</code> and start it. * * @param addr the address at which to listen, or * <code>null</code> to bind to all local addresses * @param port the port on which to listen. * @param sessionPoolSize the max number of idle sessions allowed by the * pool */ public NGServer(InetAddress addr, int port, int sessionPoolSize) { init(addr, port, sessionPoolSize); }
public static void main(String[] args) throws UnknownHostException { for (String arg : args) { if (!( ADDRESS_REGEXP.matcher(arg).matches() || PORT_REGEXP.matcher(arg).matches() || ADDRESSPORT_REGEXP.matcher(arg).matches())) { throw new RuntimeException("JRuby's Nailgun server can only receive arguments via -X or -J-D properties."); } } NGServer.main(args); } }
/** * Creates a new NGServer that will listen at the specified address and on * the specified port with the default session pool size. This does * <b>not</b> cause the server to start listening. To do so, create a new * <code>Thread</code> wrapping this * <code>NGServer</code> and start it. * * @param addr the address at which to listen, or * <code>null</code> to bind to all local addresses * @param port the port on which to listen. * @param sessionPoolSize the max number of idle sessions allowed by the * pool */ public NGServer(InetAddress addr, int port) { init(addr, port, DEFAULT_SESSIONPOOLSIZE); }