RE: Tomcat stop and start using bash script

2018-06-29 Thread Jäkel , Guido
Hi also,

  to archive a full graceful shutdown, it's also save to just send a SIGTERM to 
the JVM running the Tomcat. This will result in invoking exactly the same 
mechanisms as the official top-level methods described by André without the 
need to start an extra VM. The PID should be available by the operating systems 
standard mechanisms as the Application Controll Framework (initd, system), by 
Java tools like jps or by system tools like ps, pidof, ... . To invoke a forced 
shutdown, one may send SIGKILL to the JVM process. 

  The advantage of both is to have a very small footprint and follow the KISS 
pragma, which may especially important in a "out-of-resources" scenario when 
the Tomcat high level interfaces (HTTP/AJP/JMX connector) become disfunctional 
as a side effect.

BTW: If the Application/Tomcat/JVM is "in trouble", one may invoke the JVM 
thread dump facility by sending a SIGQUIT to the JVM, also. Again, this may be 
a "last resort" if you can't command the Tomcat/JVM in a other way.


Greetings

Guido

>-Original Message-
>From: André Warnier (tomcat) [mailto:a...@ice-sa.com]
>Sent: Thursday, June 28, 2018 10:58 PM
>To: users@tomcat.apache.org
>Subject: Re: Tomcat stop and start using bash script
>
>Hi.
>
>I have not followe3d this thread since the beginning, but
>
>The standard tomcat distribution comes with a series of shell scripts in the 
>"bin"
>directory, which do just that : start or stop tomcat. They are conveniently 
>called
>"startup.sh" and "shutdown.sh". You could get inspiration from those.
>
>Since you are talking about bash, it is to be presumed that you are on a Linux 
>system.
>If this Linux system has a package management system, it is very likely that 
>there is a
>tomcat package available. Such tomcat packages come with startup and stop 
>scripts for
>tomcat, which make it easy to start/stop tomcat via a shell command.
>
>Furthermore, look at the on-line documentation. In
>http://tomcat.apache.org/tomcat-9.0-doc/config/server.html#Common_Attributes, 
>you will
>find the "shutdown" attribute and its explanation. It basically means that if 
>you open a
>TCP/IP socket to the given port (which you can do with bash), and send the 
>indicated
>string on that connection, tomcat will initiate a shutdown.
>
>And that's in fact what the standard shutdown.sh does, though using a 
>roundabout way : it
>starts another java jvm instance which runs another temporary instance of 
>tomcat, which
>just does one thing : send this shutdown string to the appropriate (main 
>instance of
>tomcat's) shutdown port (and then it shuts itself down).
>
>So it looks like there are a lot of ways to achieve what you want, and you 
>only need to
>pick the right one for you.


Re: Tomcat stop and start using bash script

2018-06-28 Thread tomcat

Hi.

I have not followe3d this thread since the beginning, but

The standard tomcat distribution comes with a series of shell scripts in the "bin" 
directory, which do just that : start or stop tomcat. They are conveniently called 
"startup.sh" and "shutdown.sh". You could get inspiration from those.


Since you are talking about bash, it is to be presumed that you are on a Linux 
system.
If this Linux system has a package management system, it is very likely that there is a 
tomcat package available. Such tomcat packages come with startup and stop scripts for 
tomcat, which make it easy to start/stop tomcat via a shell command.


Furthermore, look at the on-line documentation. In 
http://tomcat.apache.org/tomcat-9.0-doc/config/server.html#Common_Attributes, you will 
find the "shutdown" attribute and its explanation. It basically means that if you open a 
TCP/IP socket to the given port (which you can do with bash), and send the indicated 
string on that connection, tomcat will initiate a shutdown.


And that's in fact what the standard shutdown.sh does, though using a roundabout way : it 
starts another java jvm instance which runs another temporary instance of tomcat, which 
just does one thing : send this shutdown string to the appropriate (main instance of 
tomcat's) shutdown port (and then it shuts itself down).


So it looks like there are a lot of ways to achieve what you want, and you only need to 
pick the right one for you.



On 28.06.2018 20:13, Luis Rodríguez Fernández wrote:

Hello Danesh

Perhaps you could look for any of your tomcat connector ports, ask for the
process that is listening and kill it:

$ ppid=`lsof -i:8080 -Fp | grep p`
$ pid=`echo ${ppid#p*}`
$ kill $pid

Probably you can find something more elegant but the idea could be this
one...

Hope it helps,

Luis


2018-06-27 17:02 GMT+02:00 Leon Rosenberg :


use -force option
bin/shutdown.sh -force

regards
Leon

On Wed, Jun 27, 2018 at 5:51 PM dhanesh1212121212 
wrote:


Hi All,

Trying to stop and start tomcat in production using bash script for war
deployment.

If tomcat not stopped properly then how we can kill the correct process

and

make sure it's stopped correctly.

Regards,
Dhanesh M.










-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat stop and start using bash script

2018-06-28 Thread Luis Rodríguez Fernández
Hello Danesh

Perhaps you could look for any of your tomcat connector ports, ask for the
process that is listening and kill it:

$ ppid=`lsof -i:8080 -Fp | grep p`
$ pid=`echo ${ppid#p*}`
$ kill $pid

Probably you can find something more elegant but the idea could be this
one...

Hope it helps,

Luis


2018-06-27 17:02 GMT+02:00 Leon Rosenberg :

> use -force option
> bin/shutdown.sh -force
>
> regards
> Leon
>
> On Wed, Jun 27, 2018 at 5:51 PM dhanesh1212121212 
> wrote:
>
> > Hi All,
> >
> > Trying to stop and start tomcat in production using bash script for war
> > deployment.
> >
> > If tomcat not stopped properly then how we can kill the correct process
> and
> > make sure it's stopped correctly.
> >
> > Regards,
> > Dhanesh M.
> >
>



-- 

"Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."

- Samuel Beckett


Re: Tomcat stop and start using bash script

2018-06-27 Thread Leon Rosenberg
use -force option
bin/shutdown.sh -force

regards
Leon

On Wed, Jun 27, 2018 at 5:51 PM dhanesh1212121212 
wrote:

> Hi All,
>
> Trying to stop and start tomcat in production using bash script for war
> deployment.
>
> If tomcat not stopped properly then how we can kill the correct process and
> make sure it's stopped correctly.
>
> Regards,
> Dhanesh M.
>


Tomcat stop and start using bash script

2018-06-27 Thread dhanesh1212121212
Hi All,

Trying to stop and start tomcat in production using bash script for war
deployment.

If tomcat not stopped properly then how we can kill the correct process and
make sure it's stopped correctly.

Regards,
Dhanesh M.