Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bashScriptConfigLocation config invalid #1076

Closed
nonpool opened this issue Dec 7, 2017 · 5 comments
Closed

bashScriptConfigLocation config invalid #1076

nonpool opened this issue Dec 7, 2017 · 5 comments
Labels
documentation Documentation should be extended or updated universal Zip, tar.gz, tgz and bash issues windows

Comments

@nonpool
Copy link

nonpool commented Dec 7, 2017

Expected behaviour

When I upgrade from 1.2.0-M8 to 1.3.2 later,bashScriptConfigLocation config is invalid.when i use the commandline sbt dist pacakge still exists conf/application.ini, and my own setting config/jvm.ini also exists

Actual behaviour

only exits my setting file

Information

  • What sbt-native-packager are you using
    1.3.2
  • What sbt version
    0.13.13
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian )
    Windows10
  • What package are you building (e.g. docker, rpm, ...)
    Universal zip
  • What version has your build tool (find out with e.g. rpm --version)
  • What is your target system (e.g. Ubuntu 16.04, CentOS 7)
@muuki88
Copy link
Contributor

muuki88 commented Dec 8, 2017

Thanks for your bug report 😀

Can you provide a simple build.sbt to reproduce this? Or even better a regression test?

@nonpool
Copy link
Author

nonpool commented Dec 9, 2017

I change back to 1.2.0-M8 package is right.don't exits conf/application.ini.
my build.sbt main content:


enablePlugins(JavaServerAppPackaging)

mappings in Universal ++= {
  // optional example illustrating how to copy additional directory
  directory("scripts") ++
    // copy configuration files to config directory
    contentOf("src/main/resources").filter(x => !x._2.endsWith("Mapper.xml"))
      .filter(x => !x._2.equals("mybatis-config.xml")).toMap.mapValues("config/" + _) ++
    contentOf("bash").toMap.mapValues("bin/" + _)
}



scriptClasspath := Seq("../config/") ++ Seq("*")

javaOptions in Universal ++= Seq(
  // -J params will be added as jvm parameters X开头的jvm参数需要 -J
  "-J-Xmx8g",
  "-J-Xms2g",
  "-J-XX:+UseG1GC",
  "-J-Xloggc:../gc.log",
  "-J-XX:+PrintGCDateStamps",
  "-J-XX:+PrintGCDetails "
//  "-Dcom.sun.management.jmxremote.port=1090",
//  "-Dcom.sun.management.jmxremote.ssl=false",
//  "-Dcom.sun.management.jmxremote.authenticate=false"
)
//生成jvm配置文件
bashScriptConfigLocation := Some("${app_home}/../config/jvm.ini")

@dwickern
Copy link
Collaborator

dwickern commented Dec 9, 2017

It might be related to #1042 if you have both the bat and bat script plugins. You create the jvm.ini for the bash script and you get an application.ini for the bat script. This should not cause any problem though.

If you set batScriptConfigLocation := bashScriptConfigLocation.value do you still get the second .ini?

@muuki88 muuki88 added documentation Documentation should be extended or updated universal Zip, tar.gz, tgz and bash issues windows labels Dec 10, 2017
@muuki88
Copy link
Contributor

muuki88 commented Dec 10, 2017

This is a documentation issue. @dwickern identified the issue correctly. We provide two start scripts bash and bat. Both can be configured independently ( which is crucial as they are not the same ):

javaOptions in Universal

If you add anything to the javaOptions in Universal native-packager will try to generate configuration files for bash and bat scripts that take these options into account.

Configuring bash and bat config files

bashScriptConfigLocation:
points to the location where the config file will be located at the target system! For this reason native-packager strips away the ${app_home}/../ when generating the universal:mappings.

${app_home}/../conf/application.ini becomes conf/application.ini in the mappings. You can check by calling show universal:mappings

[info] * (/sbt-native-packager/test-project-simple/target/universal/tmp/conf/application.ini,conf/jvmopts)

This logic is very specific for the bashScriptConfigLocation. The app_home is a variable available only in our start script. This looks very hacky, but from our perspective the only relevant variable when setting a configuration file: relative to the app_home directory. Still you can apply absolute paths if you know what you are doing 😎

batScriptConfigLocation
points to the location where the config file will be located at the target system, too! Native-packager handles the path here the same way as the basScriptConfigLocation. It strips out a specific prefix: %APP_HOME% and replaces all \ with / when generating the universal:mappings.

%APP_HOME%\conf\application.ini becomes conf/application.ini.

Conclusion

You need to configure both, bashScriptConfigLocation and batScriptConfigLocation if you want only a single jvmopts file. Otherwise native-packager will generate the bash and bat script config files.

bashScriptConfigLocation := Some("${app_home}/../conf/jvmopts")
batScriptConfigLocation := Some("%APP_HOME%\\conf\\jvmopts")

We need to make this more explicit in the documentation :)

@nonpool
Copy link
Author

nonpool commented Dec 11, 2017

thanks,perfect solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation should be extended or updated universal Zip, tar.gz, tgz and bash issues windows
Projects
None yet
Development

No branches or pull requests

3 participants