Linux/Java: Process terminates itself if started in background
-
I'm fighting with some
piece of crapsoftware written in Java. It starts just fine, but the very second I'm trying to launch it with a & to let it run in the background, it will terminate itself after 3 seconds. Output isn't helpful at all.Working:
java -jar /opt/vendor/bin/software.jarNot working:
java -jar /opt/vendor/bin/software.jar &I'm a bit curious about this: The java process shouldn't care if it is running in the background or not. Tried different things like output redirection, nohup, disown etc. to no avail. Last resort would be a agetty autologin session running in the background, but I really don't want to do that. Altering the software is not an option.
System is Ubuntu 16.04 with ppa:webupd8team/java, a specific requirement for this software.
Any ideas?
-
Update: This seems to be related to Jetty (an embedded webserver) and/or "Apache Felix Gogo" (a framework of some sort, maybe related to bundling). As far as I can tell from looking at the output, the process hangs just before Jetty gets initialized. It will do this just fine when it is running in the foreground.
-
Solved... Seems like Gogo is creating its own shell for whatever reason and this was crashing when running in the background, e.g. detached from its parent shell.
Found a Gogo-parameter (gosh.args=--nointeractive) here
- http://apache-felix.18485.x6.nabble.com/Gogo-shell-on-standard-input-output-streams-td4845969.html#a4845970 and here
- http://stackoverflow.com/questions/14323225/making-apache-felix-gogo-not-open-a-local-console
Basically, the following command line will do:
java -Dgosh.args=--nointeractive -jar bin/felix.jar &With stdout and stderr redirection:
java -Dgosh.args=--nointeractive -jar bin/felix.jar > /var/log/myapp.log 2>&1 & -
At least it's not purposely breaking shell inheritance like IDEAS on IRIX used to do. Looked absolutely horrible when another sysadmin looked at those systems. Still, that's just terrible practice today.
-
@travisdh1 said in Linux/Java: Process terminates itself if started in background:
At least it's not purposely breaking shell inheritance like IDEAS on IRIX used to do. Looked absolutely horrible when another sysadmin looked at those systems. Still, that's just terrible practice today.
Yeah, I can't say what I am thinking about it without making this site PEGI 18...
I'm still wrestling with it, but it looks like I'm going to win this one.
-
@thwr said in Linux/Java: Process terminates itself if started in background:
@travisdh1 said in Linux/Java: Process terminates itself if started in background:
At least it's not purposely breaking shell inheritance like IDEAS on IRIX used to do. Looked absolutely horrible when another sysadmin looked at those systems. Still, that's just terrible practice today.
Yeah, I can't say what I am thinking about it without making this site PEGI 18...
I'm thinking it right along with you, between bouts of nausea from the memories.
I'm still wrestling with it, but it looks like I'm going to win this one.
Good! Beat that POS into submission!
-
@travisdh1 said in Linux/Java: Process terminates itself if started in background:
@thwr said in Linux/Java: Process terminates itself if started in background:
@travisdh1 said in Linux/Java: Process terminates itself if started in background:
At least it's not purposely breaking shell inheritance like IDEAS on IRIX used to do. Looked absolutely horrible when another sysadmin looked at those systems. Still, that's just terrible practice today.
Yeah, I can't say what I am thinking about it without making this site PEGI 18...
I'm thinking it right along with you, between bouts of nausea from the memories.
I'm still wrestling with it, but it looks like I'm going to win this one.
Good! Beat that POS into submission!
Oh I did. It tried to cheat on my two more times by blocking the whole shell process despite being forced to background (app &) and using the same TCP port for two different instances but ... finally gave up.
Thanks for your coaching