Debug standalone mode, plus various bugfixes
This commit is contained in:
@@ -190,7 +190,7 @@ class MacMahon(
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
placementParams: PlacementParams = PlacementParams(
|
placementParams: PlacementParams = PlacementParams(
|
||||||
Criterion.NBW, Criterion.SOSW, Criterion.SOSOSW
|
Criterion.MMS, Criterion.SOSM, Criterion.SOSOSM
|
||||||
),
|
),
|
||||||
var mmFloor: Int = -20, // 20k
|
var mmFloor: Int = -20, // 20k
|
||||||
var mmBar: Int = 0 // 1D
|
var mmBar: Int = 0 // 1D
|
||||||
|
@@ -108,7 +108,9 @@
|
|||||||
<directory>${project.build.directory}/generated-resources/css</directory>
|
<directory>${project.build.directory}/generated-resources/css</directory>
|
||||||
<targetPath>css</targetPath>
|
<targetPath>css</targetPath>
|
||||||
<includes>
|
<includes>
|
||||||
|
<include>index.css</include>
|
||||||
<include>main.css</include>
|
<include>main.css</include>
|
||||||
|
<include>tour.css</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
</webResources>
|
</webResources>
|
||||||
|
@@ -6,14 +6,17 @@ import okhttp3.OkHttpClient
|
|||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
import okhttp3.internal.EMPTY_REQUEST
|
||||||
|
import org.jeudego.pairgoth.web.WebappManager
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
class ApiTool {
|
class ApiTool {
|
||||||
companion object {
|
companion object {
|
||||||
const val JSON = "application/json"
|
const val JSON = "application/json"
|
||||||
const val XML = "application/xml"
|
const val XML = "application/xml"
|
||||||
val apiRoot = System.getProperty("pairgoth.api.external.url")?.let { "${it.removeSuffix("/")}/" }
|
val apiRoot by lazy {
|
||||||
|
WebappManager.getProperty("api.external.url")?.let { "${it.removeSuffix("/")}/" }
|
||||||
?: throw Error("no configured API url")
|
?: throw Error("no configured API url")
|
||||||
|
}
|
||||||
val logger = LoggerFactory.getLogger("api")
|
val logger = LoggerFactory.getLogger("api")
|
||||||
}
|
}
|
||||||
private val client = OkHttpClient()
|
private val client = OkHttpClient()
|
||||||
|
@@ -19,7 +19,9 @@ class ApiServlet : AsyncProxyServlet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val apiRoot = System.getProperty("pairgoth.api.external.url")?.let { "${it.removeSuffix("/")}" }
|
private val apiRoot by lazy {
|
||||||
|
WebappManager.getProperty("api.external.url")?.let { "${it.removeSuffix("/")}" }
|
||||||
?: throw Error("no configured API url")
|
?: throw Error("no configured API url")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ import javax.servlet.http.HttpServletResponse
|
|||||||
|
|
||||||
class ImportServlet: HttpServlet() {
|
class ImportServlet: HttpServlet() {
|
||||||
|
|
||||||
private val api = ApiTool()
|
private val api by lazy { ApiTool() }
|
||||||
|
|
||||||
override fun doPost(req: HttpServletRequest, resp: HttpServletResponse) {
|
override fun doPost(req: HttpServletRequest, resp: HttpServletResponse) {
|
||||||
val uploads = Upload.handleFileUpload(req)
|
val uploads = Upload.handleFileUpload(req)
|
||||||
|
@@ -32,7 +32,6 @@ import java.util.*
|
|||||||
import java.util.jar.JarFile
|
import java.util.jar.JarFile
|
||||||
import java.util.regex.Pattern
|
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
|
// register a shutdown hook for any global necessary cleanup
|
||||||
@@ -67,6 +66,7 @@ private fun readProperties() {
|
|||||||
val properties = File("./pairgoth.properties")
|
val properties = File("./pairgoth.properties")
|
||||||
if (properties.exists()) {
|
if (properties.exists()) {
|
||||||
serverProps.load(FileReader(properties))
|
serverProps.load(FileReader(properties))
|
||||||
|
}
|
||||||
serverProps.entries.forEach { entry ->
|
serverProps.entries.forEach { entry ->
|
||||||
val property = entry.key as String
|
val property = entry.key as String
|
||||||
val value = entry.value as String
|
val value = entry.value as String
|
||||||
@@ -75,7 +75,6 @@ private fun readProperties() {
|
|||||||
System.setProperty("pairgoth.$property", value)
|
System.setProperty("pairgoth.$property", value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// we want colorized output on linux
|
// we want colorized output on linux
|
||||||
if (System.getProperty("os.name") == "Linux")
|
if (System.getProperty("os.name") == "Linux")
|
||||||
{
|
{
|
||||||
@@ -118,7 +117,7 @@ private fun launchServer() {
|
|||||||
// create webapps contexts
|
// create webapps contexts
|
||||||
val webAppContexts = mutableListOf<WebAppContext>()
|
val webAppContexts = mutableListOf<WebAppContext>()
|
||||||
val mode = serverProps["mode"] ?: "standalone"
|
val mode = serverProps["mode"] ?: "standalone"
|
||||||
if (mode == "server" || mode == "standalone") webAppContexts.add(createContext("api", "/api"))
|
if (mode == "server" || mode == "standalone") webAppContexts.add(createContext("api", "/api/tour"))
|
||||||
if (mode == "client" || mode == "standalone") webAppContexts.add(createContext("view", "/"))
|
if (mode == "client" || mode == "standalone") webAppContexts.add(createContext("view", "/"))
|
||||||
|
|
||||||
// special handling for logger properties
|
// special handling for logger properties
|
||||||
@@ -132,7 +131,12 @@ private fun launchServer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val webappUrl = serverProps.getProperty("webapp.url")?.let { URL(it) } ?: throw Error("missing property webapp.url")
|
val webappUrl = URL(
|
||||||
|
serverProps.getProperty("webapp.protocol") ?: throw Error("missing property webapp.protocol"),
|
||||||
|
serverProps.getProperty("webapp.protocol") ?: throw Error("missing property webapp.protocol"),
|
||||||
|
serverProps.getProperty("webapp.port")?.toInt() ?: 80,
|
||||||
|
"/"
|
||||||
|
)
|
||||||
val secure = webappUrl.protocol == "https"
|
val secure = webappUrl.protocol == "https"
|
||||||
|
|
||||||
// create server
|
// create server
|
||||||
@@ -156,6 +160,9 @@ private fun launchServer() {
|
|||||||
private fun createContext(webapp: String, contextPath: String) = WebAppContext().also { context ->
|
private fun createContext(webapp: String, contextPath: String) = WebAppContext().also { context ->
|
||||||
context.war = "$tmp/pairgoth/webapps/$webapp-webapp-$version.war"
|
context.war = "$tmp/pairgoth/webapps/$webapp-webapp-$version.war"
|
||||||
context.contextPath = contextPath
|
context.contextPath = contextPath
|
||||||
|
if (webapp == "api") {
|
||||||
|
context.allowNullPathInfo = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildSecureConnector(server: Server, port: Int): ServerConnector {
|
private fun buildSecureConnector(server: Server, port: Int): ServerConnector {
|
||||||
|
@@ -1,5 +1,19 @@
|
|||||||
webapp.url = https://localhost:8443
|
mode = standalone
|
||||||
|
env = prod
|
||||||
|
# webapp connector
|
||||||
|
webapp.protocol = http
|
||||||
|
webapp.interface = localhost
|
||||||
|
webapp.port = 8080
|
||||||
|
webapp.context = /
|
||||||
|
webapp.external.url = http://localhost:8080
|
||||||
|
|
||||||
|
# api connector
|
||||||
|
api.protocol = http
|
||||||
|
api.interface = localhost
|
||||||
|
api.port = 8080
|
||||||
|
api.context = /api/tour
|
||||||
|
api.external.url = http://localhost:8080/api/
|
||||||
|
|
||||||
webapp.ssl.key = jar:file:$jar!/ssl/localhost.key
|
webapp.ssl.key = jar:file:$jar!/ssl/localhost.key
|
||||||
webapp.ssl.pass =
|
webapp.ssl.pass =
|
||||||
webapp.ssl.cert = jar:file:$jar!/ssl/localhost.crt
|
webapp.ssl.cert = jar:file:$jar!/ssl/localhost.crt
|
||||||
mode = standalone
|
|
||||||
|
Reference in New Issue
Block a user