7 Replies Latest reply on May 7, 2010 1:47 AM by Daniel Cullender

    jboss 4.0.4 shutdown by kill -9 pid

    nobleman nobleman Newbie

      Hi,

        I am using jboss 4.0.4 application server & using log4j for logging. When server is running if i want to shutdown, i use kill -9 pid

      pid is jboss process id. If i do that it doesn't show up into server.log. I want to show in the log message if somebody ( operation ) kill jboss using above comand. What do i need to change in run.sh or any jboss config file.

       

      Please Help.

       

      Thanks

        • 1. Re: jboss 4.0.4 shutdown by kill -9 pid
          nobleman nobleman Newbie

          somebody suggested that i should use JAVA_OPTS="$JAVA_OPTS -Djboss.aop.verbose=true" in run.sh. I tried but still it doesn't show up in log when it is killed.

          • 2. Re: jboss 4.0.4 shutdown by kill -9 pid
            Daniel Cullender Newbie

            Is there any reason why are you not using the standard jboss shutdown script? Kill -9 will terminate the process on an OS level, so jboss will not log anything. I think you can somehow catch a kill signal (not a -9 though) and cause a graceful shutdown. Also look at adding a Runtime.addShutdownHook.

            • 3. Re: jboss 4.0.4 shutdown by kill -9 pid
              nobleman nobleman Newbie

              Thanks Danial for reply. I do have shutdown script but in production some times jboss goes down for some reason and there is no log how it went down. Probably somebody might have killed the process accidentally. I want to find out reason why it goes down in future. So if i can log it in server.log if it is killed by using such command or something.

              • 4. Re: jboss 4.0.4 shutdown by kill -9 pid
                David Lloyd Master

                Never use kill -9 to shut down an app server.  At the OS level, this terminates the process immediately - thus nothing is given the chance to shut down and clean up resources.  Transactions can be left unresolved; files left partially written.  This is a bad, bad practice.  If you use SIGTERM or SIGINT to shut down JBossAS, it will shut down correctly and the information will be in the log properly.  Using the shutdown script effectively works the same way as delivering a SIGINT to the process.

                • 5. Re: jboss 4.0.4 shutdown by kill -9 pid
                  nobleman nobleman Newbie

                  Thanks David for your input. I agree with you that we should not use kill -9. But in out prod system, since jboss goes down some times and never have log of it. If it is shutdown by script than it shows log. So if somebody stop the process by some means and we don't know what is happening why jboss is going down. I want to keep tack of how it went down. Any suggestions ?

                  • 6. Re: jboss 4.0.4 shutdown by kill -9 pid
                    Stathis Rouvas Newbie

                    If you have people that can arbirtarily kill process in your server, you have more serious problems than keeping a log of when the server went down.

                     

                    Having said that, check out the documentation of the "trap" command (provided by bash if you're on Linux) or by the shell.

                     

                    .e.g, to disallow shutting down by kill:

                     

                    trap "" 2 15 18 # Ignore SIGINT, SIGTERM and SIGTSTP

                     

                    this has to be inserted in run.sh.

                     

                    Be very carefull with that stuff, they bite.

                     

                    -Stathis

                    • 7. Re: jboss 4.0.4 shutdown by kill -9 pid
                      Daniel Cullender Newbie

                      I agree with Stathis and the previous replies, you should not have people arbitrarily killing your jboss instance. Have a relook at your security model.

                       

                      As another alternative (since we are already getting out of hand ...) :

                       

                      create a script called "kill.sh". In this script, you can log what's happening, send a mail or do whatever you need to do when the kill command is executed.

                       

                      You then set up an alias of  kill to kill.sh. So every time someone issues a kill command, your script gets invoked and logs / notfies before issuing the kill command.

                       

                      Example :

                       

                      in my kill.sh script


                      echo "Killing ..."
                      kill $@

                       

                      I then set up an alias in my .bashrc :

                       

                      alias kill='/path/kill.sh"


                       

                      now every time you call 'kill' you will see an output "Killing ...". As mentioned previously you can extend this and mail/ log to file etc.