From e1997eb8ccc2ac16f3978c1afc9805d6c5189149 Mon Sep 17 00:00:00 2001 From: Robinson Date: Sun, 28 May 2023 17:03:05 +0200 Subject: [PATCH] getting the aeron log location is now static public. --- src/dorkbox/network/Configuration.kt | 74 ++++++++++++++-------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/dorkbox/network/Configuration.kt b/src/dorkbox/network/Configuration.kt index ef3e25f5..08f09e56 100644 --- a/src/dorkbox/network/Configuration.kt +++ b/src/dorkbox/network/Configuration.kt @@ -199,6 +199,42 @@ abstract class Configuration { else -> { true } } } + + /** + * Depending on the OS, different base locations for the Aeron log directory are preferred. + */ + fun defaultAeronLogLocation(logger: KLogger = NOP_LOGGER): File { + return when { + OS.isMacOsX -> { + // does the recommended location exist?? + + // Default is to try the RAM drive + val suggestedLocation = File("/Volumes/DevShm") + if (suggestedLocation.exists()) { + suggestedLocation + } + else { + if (logger !== NOP_LOGGER) { + if (!alreadyShownTempFsTips) { + alreadyShownTempFsTips = true + logger.info( + "It is recommended to create a RAM drive for best performance. For example\n" + "\$ diskutil erasevolume HFS+ \"DevShm\" `hdiutil attach -nomount ram://\$((2048 * 2048))`" + ) + } + } + + OS.TEMP_DIR + } + } + OS.isLinux -> { + // this is significantly faster for linux than using the temp dir + File("/dev/shm/") + } + else -> { + OS.TEMP_DIR + } + } + } } /** @@ -596,42 +632,6 @@ abstract class Configuration { internal var contextDefined: Boolean = false - /** - * Depending on the OS, different base locations for the Aeron log directory are preferred. - */ - private fun suggestAeronLogLocation(logger: KLogger): File { - return when { - OS.isMacOsX -> { - // does the recommended location exist?? - - // Default is to try the RAM drive - val suggestedLocation = File("/Volumes/DevShm") - if (suggestedLocation.exists()) { - suggestedLocation - } - else { - if (logger !== NOP_LOGGER) { - if (!alreadyShownTempFsTips) { - alreadyShownTempFsTips = true - logger.info( - "It is recommended to create a RAM drive for best performance. For example\n" + "\$ diskutil erasevolume HFS+ \"DevShm\" `hdiutil attach -nomount ram://\$((2048 * 2048))`" - ) - } - } - - OS.TEMP_DIR - } - } - OS.isLinux -> { - // this is significantly faster for linux than using the temp dir - File("/dev/shm/") - } - else -> { - OS.TEMP_DIR - } - } - } - /** * Validates the current configuration. Throws an exception if there are problems. */ @@ -742,7 +742,7 @@ abstract class Configuration { */ var dir = aeronDirectory if (dir == null) { - val baseFileLocation = suggestAeronLogLocation(logger) + val baseFileLocation = defaultAeronLogLocation(logger) val aeronLogDirectory = if (uniqueAeronDirectory) { // this is incompatible with IPC, and will not be set if IPC is enabled (error will be thrown on validate) File(baseFileLocation, "aeron_${mediaDriverId()}")