diff --git a/src/main/java/stirling/software/SPDF/config/AppConfig.java b/src/main/java/stirling/software/SPDF/config/AppConfig.java index 13e7fe2bcc8..6d8786e8564 100644 --- a/src/main/java/stirling/software/SPDF/config/AppConfig.java +++ b/src/main/java/stirling/software/SPDF/config/AppConfig.java @@ -99,6 +99,27 @@ public boolean runningInDocker() { return Files.exists(Paths.get("/.dockerenv")); } + @Bean(name = "configDirMounted") + public boolean isRunningInDockerWithConfig() { + Path dockerEnv = Paths.get("/.dockerenv"); + // default to true if not docker + if (!Files.exists(dockerEnv)) { + return true; + } + + Path mountInfo = Paths.get("/proc/1/mountinfo"); + // this should always exist, if not some unknown usecase + if (!Files.exists(mountInfo)) { + return true; + } + + try { + return Files.lines(mountInfo).anyMatch(line -> line.contains(" /configs ")); + } catch (IOException e) { + return false; + } + } + @Bean(name = "bookAndHtmlFormatsInstalled") public boolean bookAndHtmlFormatsInstalled() { String installOps = System.getProperty("INSTALL_BOOK_AND_ADVANCED_HTML_OPS"); diff --git a/src/main/java/stirling/software/SPDF/service/PostHogService.java b/src/main/java/stirling/software/SPDF/service/PostHogService.java index a2d3d485f5d..3127e2af541 100644 --- a/src/main/java/stirling/software/SPDF/service/PostHogService.java +++ b/src/main/java/stirling/software/SPDF/service/PostHogService.java @@ -31,11 +31,13 @@ public class PostHogService { private final ApplicationProperties applicationProperties; private final UserServiceInterface userService; private final Environment env; + private boolean configDirMounted; @Autowired public PostHogService( PostHog postHog, @Qualifier("UUID") String uuid, + @Qualifier("configDirMounted") boolean configDirMounted, @Qualifier("appVersion") String appVersion, ApplicationProperties applicationProperties, @Autowired(required = false) UserServiceInterface userService, @@ -46,6 +48,7 @@ public PostHogService( this.applicationProperties = applicationProperties; this.userService = userService; this.env = env; + this.configDirMounted = configDirMounted; captureSystemInfo(); } @@ -80,6 +83,7 @@ public Map captureServerMetrics() { deploymentType = "DOCKER"; } metrics.put("deployment_type", deploymentType); + metrics.put("mounted_config_dir", configDirMounted); // System info metrics.put("os_name", System.getProperty("os.name"));