From 7a9de4f71100a3809532ae02c642d48edd38cd72 Mon Sep 17 00:00:00 2001
From: Kai Reinhard <K.Reinhard@micromata.de>
Date: Mon, 19 Apr 2021 18:30:07 +0000
Subject: [PATCH] environment.sh is now created by BorgButlerApplicaiton, only for docker installations. BorgCache will now be initialized on startup, so shutdown will not fail.
---
borgbutler-docker/app/entrypoint.sh | 2 +-
borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/BorgButlerApplication.kt | 21 +++++++++++++++++++--
borgbutler-core/src/main/kotlin/de/micromata/borgbutler/config/ConfigurationHandler.kt | 12 ------------
3 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/borgbutler-core/src/main/kotlin/de/micromata/borgbutler/config/ConfigurationHandler.kt b/borgbutler-core/src/main/kotlin/de/micromata/borgbutler/config/ConfigurationHandler.kt
index a9a4fdc..2d71411 100644
--- a/borgbutler-core/src/main/kotlin/de/micromata/borgbutler/config/ConfigurationHandler.kt
+++ b/borgbutler-core/src/main/kotlin/de/micromata/borgbutler/config/ConfigurationHandler.kt
@@ -93,10 +93,6 @@
log.info("Creating borg-butlers backup directory: " + configBackupDir.absolutePath)
configBackupDir.mkdirs()
}
- val environmentFile = File(workingDir, ENVIRONMENT_FILE)
- if (!environmentFile.exists()) {
- environmentFile.writeText(ENVIRONMENT_FILE_INITIAL_CONTENT)
- }
read()
}
@@ -146,13 +142,5 @@
val yaml = FileUtils.readFileToString(configFile, Definitions.STD_CHARSET)
return YamlUtils.fromYaml(configClazz, yaml)
}
-
- private const val ENVIRONMENT_FILE = "environment.sh"
- private const val ENVIRONMENT_FILE_INITIAL_CONTENT = "#!/bin/bash\n\n" +
- "# Set the java options here:\n" +
- "#export JAVA_OPTS=-DXmx4g\n" +
- "export JAVA_OPTS=\n\n" +
- "# Set your options here (will be used for starting\n" +
- "export JAVA_ARGS=\n"
}
}
diff --git a/borgbutler-docker/app/entrypoint.sh b/borgbutler-docker/app/entrypoint.sh
index 6644126..7111d2f 100644
--- a/borgbutler-docker/app/entrypoint.sh
+++ b/borgbutler-docker/app/entrypoint.sh
@@ -61,7 +61,7 @@
#Trap SIGTERM
trap cleanup INT SIGTERM
-echo "Starting java ${JAVA_OPTS} -cp app/web/*:app/lib/* -DBorgButlerHome=/BorgButler/ -Dserver.address=0.0.0.0 ${JAVA_MAIN} ${JAVA_ARGS}"
+echo "Starting java ${JAVA_OPTS} -cp app/web/*:app/lib/* -DBorgButlerHome=/BorgButler/ -Dserver.address=0.0.0.0 -Ddocker=true ${JAVA_MAIN} ${JAVA_ARGS}"
java $JAVA_OPTS -cp app/web/*:app/lib/* -DBorgButlerHome=/BorgButler/ -Dserver.address=0.0.0.0 -Ddocker=true $JAVA_MAIN $JAVA_ARGS &
diff --git a/borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/BorgButlerApplication.kt b/borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/BorgButlerApplication.kt
index 6207080..d577112 100644
--- a/borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/BorgButlerApplication.kt
+++ b/borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/BorgButlerApplication.kt
@@ -55,9 +55,16 @@
}
SpringApplication.run(BorgButlerApplication::class.java, *args)
- if (borgButlerHome != null) {
- init(borgButlerHome)
+ init(borgButlerHome)
+ if (RunningMode.dockerMode) {
+ val workingDir = File(borgButlerHome)
+ val environmentFile = File(workingDir, ENVIRONMENT_FILE)
+ if (!environmentFile.exists()) {
+ log.info { "Creating environment file for java options (docker): ${environmentFile.absolutePath}" }
+ environmentFile.writeText(ENVIRONMENT_FILE_INITIAL_CONTENT)
+ }
}
+
// create Options object
val options = Options()
options.addOption(
@@ -134,6 +141,7 @@
System.err.println("Parsing failed. Reason: " + ex.message)
printHelp(options)
}
+ ButlerCache.getInstance() // Force initialization (otherwise shutdown may fail if cache isn't used beof).
}
@EventListener(ApplicationReadyEvent::class)
@@ -201,5 +209,14 @@
}
// 2018-12-04T22:44:58.924642
}
+
+
+ private const val ENVIRONMENT_FILE = "environment.sh"
+ private const val ENVIRONMENT_FILE_INITIAL_CONTENT = "#!/bin/bash\n\n" +
+ "# Set the java options here (for docker installation only):\n" +
+ "#export JAVA_OPTS=-DXmx4g\n" +
+ "export JAVA_OPTS=\n\n" +
+ "# Set your options here (will be used for starting\n" +
+ "export JAVA_ARGS=\n"
}
}
--
Gitblit v1.10.0