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

Using tini with java process #134

Closed
namedgraph opened this issue Apr 12, 2019 · 5 comments
Closed

Using tini with java process #134

namedgraph opened this issue Apr 12, 2019 · 5 comments

Comments

@namedgraph
Copy link

Hi,

I made my entrypoint such:

ENTRYPOINT ["/tini", "-vvv", "--", "/usr/src/.../entrypoint.sh"]

Now the entrypoint invokes a Java process:

java -jar xxx.jar

java process cannot be killed by killing the container using Ctrl+C, and adding tini to ENTRYPOINT does not make any difference.
Can tini help in this situation or do I need another solution?

Help is appreciated.

@krallin
Copy link
Owner

krallin commented Apr 13, 2019

Can you share your entrypoint code?

You probably want something like this instead to make sure the bash process doesn't stick around to receive (and essentially blackhole) the signals Tini forwards:

exec java -jar xxx.jar

@namedgraph
Copy link
Author

Smth like this:

java -jar $@" > "$json_xml" # can't use exec because the container will quit after script is done
xmllint --schema ./xsd/json2xml.xsd --noout "$json_xml" >&2
rm "$json_xml"

I tried exec, the problem is that I have some cleanup code after the Java process, but exec exits the whole script no matter success or error, and that code never gets executed.

@krallin
Copy link
Owner

krallin commented Apr 13, 2019

Thanks. That's not going to work right now with Tini, but there is a fork that allows for post-processing commands, have a look at that: #129

I haven't had time to figure out whether this makes sense to incorporate in Tini and to do so, so you'll have to build this yourself, but I think that's what you need here.

@krallin krallin closed this as completed Apr 13, 2019
@krallin
Copy link
Owner

krallin commented Apr 13, 2019

Alternatively, you might want to try passing -g to Tini to signal the entire process group (i.e. bash + java) 😄.

@namedgraph
Copy link
Author

I went with this kind of solution: https://stackoverflow.com/a/29890106/1003113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants