ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Linux/Java: Process terminates itself if started in background

    IT Discussion
    linux
    2
    7
    817
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thwrT
      thwr
      last edited by thwr

      I'm fighting with some piece of crap software 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.jar

      Not 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?

      1 Reply Last reply Reply Quote 0
      • thwrT
        thwr
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • thwrT
          thwr
          last edited by thwr

          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 &

          1 Reply Last reply Reply Quote 1
          • travisdh1T
            travisdh1
            last edited by

            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.

            thwrT 1 Reply Last reply Reply Quote 1
            • thwrT
              thwr @travisdh1
              last edited by

              @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.

              travisdh1T 1 Reply Last reply Reply Quote 1
              • travisdh1T
                travisdh1 @thwr
                last edited by

                @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!

                thwrT 1 Reply Last reply Reply Quote 1
                • thwrT
                  thwr @travisdh1
                  last edited by

                  @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 😉

                  1 Reply Last reply Reply Quote 1
                  • 1 / 1
                  • First post
                    Last post