Centralized versionning, and web server ressources cache fooling
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.jeudego.pairgoth</groupId>
|
||||
<artifactId>engine-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>api-webapp</artifactId>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
</httpConnector>
|
||||
<systemProperties>
|
||||
<pairgoth.env>${pairgoth.env}</pairgoth.env>
|
||||
<pairgoth.version>${project.version}</pairgoth.version>
|
||||
<pairgoth.version>${pairgoth.version}</pairgoth.version>
|
||||
<pairgoth.api.external.url>${pairgoth.api.external.url}</pairgoth.api.external.url>
|
||||
<pairgoth.webapp.external.url>${pairgoth.webapp.external.url}</pairgoth.webapp.external.url>
|
||||
<pairgoth.store>${pairgoth.store}</pairgoth.store>
|
||||
|
@@ -62,8 +62,7 @@ class WebappManager : ServletContextListener, ServletContextAttributeListener, H
|
||||
properties[(key as String).removePrefix(PAIRGOTH_PROPERTIES_PREFIX)] = value
|
||||
}
|
||||
|
||||
val env = properties.getProperty("env")
|
||||
logger.info("Using profile $env", )
|
||||
logger.info("pairgoth server ${properties["version"]} with profile ${properties["env"]}")
|
||||
|
||||
// set system user agent string to empty string
|
||||
System.setProperty("http.agent", "")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.jeudego.pairgoth</groupId>
|
||||
<artifactId>engine-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>application</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
3
pom.xml
3
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.jeudego.pairgoth</groupId>
|
||||
<artifactId>engine-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<!-- CB: Temporary add my repository, while waiting for SSE Java server module author to incorporate my PR or for me to fork it -->
|
||||
@@ -66,6 +66,7 @@
|
||||
|
||||
<!-- pairgoth default properties -->
|
||||
<pairgoth.env>dev</pairgoth.env>
|
||||
<pairgoth.version>${project.version}</pairgoth.version>
|
||||
<pairgoth.webapp.protocol>http</pairgoth.webapp.protocol>
|
||||
<pairgoth.webapp.host>localhost</pairgoth.webapp.host>
|
||||
<pairgoth.webapp.port>8080</pairgoth.webapp.port>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.jeudego.pairgoth</groupId>
|
||||
<artifactId>engine-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>view-webapp</artifactId>
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
</httpConnector>
|
||||
<systemProperties>
|
||||
<pairgoth.env>${pairgoth.env}</pairgoth.env>
|
||||
<pairgoth.version>${pairgoth.version}</pairgoth.version>
|
||||
<pairgoth.api.external.url>${pairgoth.api.external.url}</pairgoth.api.external.url>
|
||||
<pairgoth.webapp.external.url>${pairgoth.webapp.external.url}</pairgoth.webapp.external.url>
|
||||
<pairgoth.store>${pairgoth.store}</pairgoth.store>
|
||||
|
@@ -64,11 +64,11 @@ class WebappManager : ServletContextListener, ServletContextAttributeListener, H
|
||||
properties[(key as String).removePrefix(PAIRGOTH_PROPERTIES_PREFIX)] = value
|
||||
}
|
||||
|
||||
val env = properties.getProperty("env")
|
||||
logger.info("Using profile {}", )
|
||||
logger.info("pairgoth server ${properties["version"]} with profile ${properties["env"]}")
|
||||
|
||||
// let the view be aware of the environment
|
||||
context.setAttribute("env", env)
|
||||
// publish some properties to the webapp context; for easy access from the template
|
||||
context.setAttribute("env", properties["env"])
|
||||
context.setAttribute("version", properties["version"] ?: "?")
|
||||
|
||||
// set system user agent string to empty string
|
||||
System.setProperty("http.agent", "")
|
||||
|
@@ -60,7 +60,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer" class="horz flex">
|
||||
<div id="version">pairgoth v0.1</div>
|
||||
<div id="version">pairgoth v$version</div>
|
||||
<div id="contact"><a href="mailto:pairgoth@jeudego.org">contact</a></div>
|
||||
</div>
|
||||
<div id="feedback">
|
||||
@@ -81,13 +81,13 @@
|
||||
<script type="text/javascript" src="/lib/tablesort-5.4.0/sorts/tablesort.number.min.js"></script>
|
||||
<link rel="stylesheet" href="/lib/tablesort-5.4.0/tablesort.css"/>
|
||||
<script type="text/javascript" src="/lib/imaskjs-7.1.3/imask.min.js"></script>
|
||||
<script type="text/javascript" src="/js/api.js"></script>
|
||||
<script type="text/javascript" src="/js/main.js"></script>
|
||||
<script type="text/javascript" src="/js/domhelper.js"></script>
|
||||
<script type="text/javascript" src="/js/api.js?v=$version"></script>
|
||||
<script type="text/javascript" src="/js/main.js?v=$version"></script>
|
||||
<script type="text/javascript" src="/js/domhelper.js?v=$version"></script>
|
||||
<link rel="stylesheet" href="/lib/fork-awesome-1.2.0/fork-awesome.min.css"/>
|
||||
<link rel="stylesheet" href="/css/main.css"/>
|
||||
<link rel="stylesheet" href="/css/main.css?v=$version"/>
|
||||
#if($css)
|
||||
<link rel="stylesheet" href="$css"/>
|
||||
<link rel="stylesheet" href="${css}?v=$version"/>
|
||||
#end
|
||||
<script type="text/javascript">
|
||||
const lang = '${request.lang}';
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.jeudego.pairgoth</groupId>
|
||||
<artifactId>engine-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>webserver</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
@@ -43,6 +43,8 @@ fun main(vararg args: String) {
|
||||
readProperties()
|
||||
// extract war files from main archive
|
||||
extractWarFiles()
|
||||
// publish properties as system properties
|
||||
publishProperties()
|
||||
// launch web server
|
||||
launchServer()
|
||||
} catch (t: Throwable) {
|
||||
@@ -52,7 +54,6 @@ fun main(vararg args: String) {
|
||||
|
||||
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 fun cleanup() {
|
||||
FileUtils.deleteDirectory(webapps.toFile())
|
||||
@@ -67,6 +68,9 @@ private fun readProperties() {
|
||||
if (properties.exists()) {
|
||||
serverProps.load(FileReader(properties))
|
||||
}
|
||||
}
|
||||
|
||||
private fun publishProperties() {
|
||||
serverProps.entries.forEach { entry ->
|
||||
val property = entry.key as String
|
||||
val value = entry.value as String
|
||||
@@ -92,12 +96,24 @@ private fun extractWarFiles() {
|
||||
val webappsFolderURL = getResource("/META-INF/webapps") ?: throw Error("webapps not found")
|
||||
val jarConnection = webappsFolderURL.openConnection() as JarURLConnection
|
||||
val jarFile: JarFile = jarConnection.jarFile
|
||||
val extractVersion = Regex(".*?-(\\d+\\.\\d+(?:-[^.-]+)?).war")
|
||||
var version: String? = null
|
||||
jarFile.entries().toList().filter { entry ->
|
||||
entry.name.startsWith(jarConnection.entryName)
|
||||
}.forEach { entry ->
|
||||
if (!entry.isDirectory) {
|
||||
val filename = entry.name.removePrefix("META-INF/webapps/")
|
||||
val versionMatch = extractVersion.matchEntire(filename)
|
||||
?: throw Error("Could not extract version from filename: $filename")
|
||||
val entryVersion = versionMatch.groupValues[1]
|
||||
if (version == null) {
|
||||
version = entryVersion
|
||||
serverProps["version"] = version
|
||||
} else if (version != entryVersion) {
|
||||
throw Error("Inconsistent versions found: $version and $entryVersion")
|
||||
}
|
||||
jarFile.getInputStream(entry).use { entryInputStream ->
|
||||
Files.copy(entryInputStream, webapps.resolve(entry.name.removePrefix("META-INF/webapps/")))
|
||||
Files.copy(entryInputStream, webapps.resolve(filename))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,6 +174,7 @@ private fun launchServer() {
|
||||
}
|
||||
|
||||
private fun createContext(webapp: String, contextPath: String) = WebAppContext().also { context ->
|
||||
val version = serverProps["version"] ?: throw Error("version not found")
|
||||
context.war = "$tmp/pairgoth/webapps/$webapp-webapp-$version.war"
|
||||
context.contextPath = contextPath
|
||||
if (webapp == "api") {
|
||||
|
Reference in New Issue
Block a user