void init() { active.set(true); // activate if (init.go()) { Runtime.getRuntime().addShutdownHook(new Thread(this::shutdownNow)); } }
@Override public void ready() { if (activate.go()) { onReady(); } }
public final void run() { if (once.go()) bootstrap(); }
@Override @SuppressWarnings("unchecked") public Setup scan(String... packages) { if (!bootstrappedBeans.go()) return this; beans(App.findBeans(packages).toArray()); return this; }
public synchronized static void boot() { if (boot.go()) { for (RapidoidModule module : RapidoidModules.getAll()) { module.boot(); } } }
public static void bootstrap() { if (!once.go()) return; Log.info("Bootstraping metrics"); os = ManagementFactory.getOperatingSystemMXBean(); sysCpuM = Cls.findMethod(os.getClass(), "getSystemCpuLoad"); procCpuM = Cls.findMethod(os.getClass(), "getProcessCpuLoad"); openFileDescriptorCount = Cls.findMethod(os.getClass(), "getOpenFileDescriptorCount"); threads = ManagementFactory.getThreadMXBean(); register("cpu/system", SYSTEM_CPU); register("cpu/process", PROCESS_CPU); register("mem/used", MEM_USED); register("mem/total", MEM_TOTAL); register("threads", NUM_THREADS); register("descriptors", NUM_FILE_DESC); // FIXME there are too many metrics // JMXMetrics.bootstrap(); Metrics updateMetrics = new Metrics(); updateMetrics.run(); Jobs.scheduleAtFixedRate(updateMetrics, 1, 1, TimeUnit.SECONDS); }
@Override public synchronized void flush() { // lazy init if (startChunkedResp.go()) resp.startChunkedOutputStream(); // the chunk must not be empty (empty chunk terminates the HTTP response) if (chunk.size() > 0) { resp.chunk(chunk.array(), 0, chunk.size()); chunk.reset(); } }
@Override public void ready() { if (activate.go()) { onReady(); } }
public final void run() { if (once.go()) bootstrap(); }
@SuppressWarnings("unchecked") public Setup scan(String... packages) { if (!bootstrappedBeans.go()) return this; beans(App.findBeans(packages).toArray()); return this; }
@Override public synchronized void flush() throws IOException { // lazy init if (startChunkedResp.go()) resp.startChunkedOutputStream(); // the chunk must not be empty (empty chunk terminates the HTTP response) if (chunk.size() > 0) { resp.chunk(chunk.array(), 0, chunk.size()); chunk.reset(); } }