public static void premain(Instrumentation instrumentation, @Nullable File glowrootJarFile) { boolean jbossModules = AppServerDetection.isJBossModules(); if (jbossModules) { String jbossModulesSystemPkgs = System.getProperty("jboss.modules.system.pkgs"); if (Strings.isNullOrEmpty(jbossModulesSystemPkgs)) { jbossModulesSystemPkgs = "org.glowroot.agent"; } else { jbossModulesSystemPkgs += ",org.glowroot.agent"; } System.setProperty("jboss.modules.system.pkgs", jbossModulesSystemPkgs); } String baseDirPath = System.getProperty("glowroot.base.dir"); File baseDir = BaseDir.getBaseDir(baseDirPath, glowrootJarFile); // init logger as early as possible instrumentation.addTransformer(new LogbackPatch()); initLogging(baseDir); try { ImmutableMap<String, String> properties = getGlowrootProperties(baseDir); start(baseDir, properties, instrumentation, glowrootJarFile); } catch (BaseDirLockedException e) { logBaseDirLockedException(baseDir); } catch (Throwable t) { // log error but don't re-throw which would prevent monitored app from starting startupLogger.error("Glowroot not started: {}", t.getMessage(), t); } }
@OnlyUsedByTests public static void start(Map<String, String> properties) throws Exception { String baseDirPath = properties.get("glowroot.base.dir"); File baseDir = BaseDir.getBaseDir(baseDirPath, null); // init logger as early as possible initLogging(baseDir); start(baseDir, properties, null, null); }
static void runViewer(@Nullable File glowrootJarFile) throws InterruptedException { String baseDirPath = System.getProperty("glowroot.base.dir"); File baseDir = BaseDir.getBaseDir(baseDirPath, glowrootJarFile); // init logger as early as possible initLogging(baseDir); String version; try { version = Version.getVersion(MainEntryPoint.class); ImmutableMap<String, String> properties = getGlowrootProperties(baseDir); new GlowrootFatAgentInit() .init(baseDir, null, null, properties, null, glowrootJarFile, version, true); } catch (BaseDirLockedException e) { logBaseDirLockedException(baseDir); return; } catch (Throwable t) { startupLogger.error("Glowroot cannot start: {}", t.getMessage(), t); return; } startupLogger.info("Glowroot started (version {})", version); // Glowroot does not create any non-daemon threads, so need to block jvm from exiting when // running the viewer Thread.sleep(Long.MAX_VALUE); }
private static void setProp(Path dir) { BaseDir.store(key, dir); }