简体   繁体   English

xsbt分叉的jvm具有系统属性

[英]xsbt forked jvm with system properties

I've noticed that in the latest version of xsbt the jetty container gets forked and passing system properties no longer works. 我注意到,在最新版本的xsbt中,码头容器被分叉,并且传递系统属性不再起作用。

I was looking for a simple way to pass a port number via system property when launching sbt in order to set the port for the jetty container. 我一直在寻找一种简单的方法来在启动sbt时通过系统属性传递端口号,以便为码头集装箱设置端口。 It's not clear if this is possible or not. 目前尚不清楚这是否可行。

Also, I'm running into a problem for local development because it is impossible to pass options to the container now. 另外,由于无法将选项传递给容器,因此我在本地开发中遇到了问题。 I'm not sure how to change out settings quickly and conveniently without being able to do this. 我不确定如何无法快速便捷地更改设置。 Is there a reason that the forked java process can't inherit or be passed the system props? 分叉的Java进程无法继承或传递系统道具是否有原因?

Also just curious what the reason is for needing the container to run in a forked process in the first place. 也只是好奇为什么首先需要容器在派生过程中运行的原因是什么。

I've noticed that in the latest version of xsbt the jetty container gets forked and passing system properties no longer works. 我注意到,在最新版本的xsbt中,码头容器被分叉,并且传递系统属性不再起作用。

To pass JVM system properties to the forked process , you can use either the containerForkOptions setting: 要将JVM系统属性传递给分叉的进程 ,可以使用containerForkOptions设置之一:

containerForkOptions := new ForkOptions(runJVMOptions = Seq("-Dh2g2=42"))

Or you can use javaOptions in Jetty : 或者您可以javaOptions in Jetty使用javaOptions in Jetty

javaOptions in Jetty += "-Dh2g2=42"

I was looking for a simple way to pass a port number via system property when launching sbt in order to set the port for the jetty container. 我一直在寻找一种简单的方法来在启动sbt时通过系统属性传递端口号,以便为码头集装箱设置端口。 It's not clear if this is possible or not. 目前尚不清楚这是否可行。

There are a couple ways to do this. 有两种方法可以做到这一点。 You can use the containerPort setting : 您可以使用containerPort设置

containerPort := 9090

Or you can pass arguments directly to jetty-runner: 或者,您可以将参数直接传递给jetty-runner:

containerArgs := Seq("--port", "9090")

Also just curious what the reason is for needing the container to run in a forked process in the first place. 也只是好奇为什么首先需要容器在派生过程中运行的原因是什么。

See https://github.com/earldouglas/xsbt-web-plugin/issues/136 参见https://github.com/earldouglas/xsbt-web-plugin/issues/136

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM