view doesn't need smtp loop; some cleanup
This commit is contained in:
@@ -72,12 +72,6 @@ class WebappManager : ServletContextListener, ServletContextAttributeListener, H
|
|||||||
// fail to correctly implement SSL...
|
// fail to correctly implement SSL...
|
||||||
disableSSLCertificateChecks()
|
disableSSLCertificateChecks()
|
||||||
|
|
||||||
// start smtp loop
|
|
||||||
if (properties.containsKey("smtp.host")) {
|
|
||||||
registerService("smtp", SmtpLoop(properties))
|
|
||||||
startService("smtp")
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (ioe: IOException) {
|
} catch (ioe: IOException) {
|
||||||
logger.error("webapp initialization error", ioe)
|
logger.error("webapp initialization error", ioe)
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,11 @@ import java.util.regex.Pattern
|
|||||||
|
|
||||||
fun main(vararg args: String) {
|
fun main(vararg args: String) {
|
||||||
try {
|
try {
|
||||||
|
// register a shutdown hook for any global necessary cleanup
|
||||||
|
Runtime.getRuntime().addShutdownHook(object: Thread() {
|
||||||
|
override fun run() { cleanup() }
|
||||||
|
})
|
||||||
|
|
||||||
// read default properties and provided ones, if any
|
// read default properties and provided ones, if any
|
||||||
readProperties()
|
readProperties()
|
||||||
// extract war files from main archive
|
// extract war files from main archive
|
||||||
@@ -47,8 +52,13 @@ fun main(vararg args: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val tmp = System.getProperty("java.io.tmpdir")
|
private val tmp = System.getProperty("java.io.tmpdir")
|
||||||
|
private val webapps = Path.of("${tmp}/pairgoth/webapps")
|
||||||
private val version = "1.0-SNAPSHOT" // TODO CB
|
private val version = "1.0-SNAPSHOT" // TODO CB
|
||||||
|
|
||||||
|
private fun cleanup() {
|
||||||
|
FileUtils.deleteDirectory(webapps.toFile())
|
||||||
|
}
|
||||||
|
|
||||||
private fun readProperties() {
|
private fun readProperties() {
|
||||||
val defaultProps = getResource("/server.default.properties") ?: throw Error("missing default server properties")
|
val defaultProps = getResource("/server.default.properties") ?: throw Error("missing default server properties")
|
||||||
defaultProps.openStream().use {
|
defaultProps.openStream().use {
|
||||||
@@ -76,9 +86,8 @@ private fun readProperties() {
|
|||||||
private fun extractWarFiles() {
|
private fun extractWarFiles() {
|
||||||
// val jarLocation = object{}::class.java.protectionDomain.codeSource.location
|
// val jarLocation = object{}::class.java.protectionDomain.codeSource.location
|
||||||
// prepare output directory
|
// prepare output directory
|
||||||
val targetPath = Path.of("${tmp}/pairgoth/webapps")
|
FileUtils.deleteDirectory(webapps.toFile())
|
||||||
FileUtils.deleteDirectory(targetPath.toFile())
|
Files.createDirectories(webapps)
|
||||||
Files.createDirectories(targetPath)
|
|
||||||
|
|
||||||
// extract wars
|
// extract wars
|
||||||
val webappsFolderURL = getResource("/META-INF/webapps") ?: throw Error("webapps not found")
|
val webappsFolderURL = getResource("/META-INF/webapps") ?: throw Error("webapps not found")
|
||||||
@@ -89,7 +98,7 @@ private fun extractWarFiles() {
|
|||||||
}.forEach { entry ->
|
}.forEach { entry ->
|
||||||
if (!entry.isDirectory) {
|
if (!entry.isDirectory) {
|
||||||
jarFile.getInputStream(entry).use { entryInputStream ->
|
jarFile.getInputStream(entry).use { entryInputStream ->
|
||||||
Files.copy(entryInputStream, targetPath.resolve(entry.name.removePrefix("META-INF/webapps/")))
|
Files.copy(entryInputStream, webapps.resolve(entry.name.removePrefix("META-INF/webapps/")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user