-
Notifications
You must be signed in to change notification settings - Fork 445
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
Ability to independently override different systemloader templates #937
Comments
This comment isn't accurate. linuxScriptReplacements defines additional templating replacements, like |
I've found a very hacky workaround that allows me to insert arbitrary entries into the sytemd unit, as follows:
Obviously this is a complete hack, but in some ways it's better than redefining the entire unit file template. I wonder if it would make sense for the unit file template to have something like |
Thanks @ANorwell for the detailed explanation and concrete use cases. From your good research and the one example you are giving, I assume you use native-packager enablePlugin(SystemdPlugin)
systemdSuccessExitStatus := Seq("0", "1") If you like to have additional settings, you can submit a pull request. The hacky workaround is actually how things work in native-packager. The
If this is the case, then we have a bug that must be fixed. The linuxStartScriptTemplate setting is responsible for the start template. It looks for a file in a specific place or you override the setting. If that doesn't help, can you provide a minimal example to reproduce this error? |
I've created a repo with a minimal reproduction. The readme for that repo describes in detail how to reproduce. I also verified that the PR I opened related to this fixes that issue (although as that PR mentions, it's a breaking change and may not be the right approach).
I want to explain this more. My original goal when encountering this issue was to create a systemd unit file that increases the max number of file descriptors. The way you would do this would be to add the line My first attempt around this was to redefine the entire template, using the approach in the repo. My second attempt around this was use the
To me this is quite hacky and probably not a use that you were intending. I think that possibly an easy way to allow for arbitrary lines such as max number of files to be added to the unit handle would be to have a catch-all template, such as
|
Thanks a lot @ANorwell for your PR and fixing this bug. I already commented on the PR.
This would be possible ( like the
However I'm not sure if this is scalable approach as we spam the user with a lot of settings. Native-packager also provides a lot of helpers to do the same task. E.g. we could also add an autoImported helper if the linuxScriptReplacements ++= systemdAddUnitEntries(
"SuccessExitStatus" -> "0, 1, 130",
"OtherSetting" -> "Value"
) WDYT? |
This sounds great! Much more useable than what I was suggesting. |
Implemented in #938 |
sbt-native-packager provides the ability to include a single override template in (e.g. for systemd)
templates/systemloader/systemd
. Additionally, there are multiple default templates provided, which are used as fallbacks, e.g. for systemdloader_functions
andstart_template
.However, it seems that providing the override template will cause it to override all templates. It doesn't seem like there's a way to override
start_template
without overridingloader_functions
as well, with the same file. This rarely makes sense.To give a concrete example, for systemd I want to modify the unit definition beyond what's in
start_template
. So, I providetemplates/systemloader/systemd
with my modified unit template. But, this results in this template also being used for loader_functions and being inserted into the start script, which fails to run.To me, the solution here is to allow users to provide
loader_functions
andstart_template
files, not a singlesystemd
file. This would be somewhat of a breaking change, though.The text was updated successfully, but these errors were encountered: