"pattern" is a literal pattern on which you would grep on a full ps output.
That could be 'java', but you probably want to note something more
specific, depending on the full command line which starts your tomcat.
Given that tomcat sometimes doesn't stop, as in hangs or as in takes a long
time to stop, I combine this with a custom module i wrote, that has
different options to check on a process, whether it stopped, and to kill it
nicely, or later on not so nicely:
I would also point out that "/etc/init.d/tomcat7_stop instance01"
does not look like a standard init script, this will not work with the
service module.
I've used multi instance tomcat scripts before but they were either:
/etc/init.d/tomcat7_instance01 stop
works using tomcat7_instance01 as service name
or
/etc/init.d/tomcat7 stop instance01
which is supported by the arguments parameter arguments=instance01
but failed to run the second command: pkill -9 -u tomcat7_01
received this output:
TASK: [stop tomcat] ***********************************************************
failed: [194...*] => {“changed”: true, “cmd”: [“/etc/init.d/tomcat7_stop”, “instance01”], “delta”: “0:00:01.090791”, “end”: “2014-12-11 20:30:35.019231”, “rc”: 1, “start”: “2014-12-11 20:30:33.928440”}
stderr: Dec 11, 2014 8:30:34 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:499)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:371)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:458)
stdout: Using CATALINA_BASE: /var/tomcat7_instances/instance01
Using CATALINA_HOME: /var/tomcat7_instances/instance01
Using CATALINA_TMPDIR: /var/tomcat7_instances/instance01/temp
Using JRE_HOME: /usr/java/jdk
Using CLASSPATH: /var/tomcat7_instances/instance01/bin/bootstrap.jar:/var/tomcat7_instances/instance01/bin/tomcat-juli.jar
FATAL: all hosts have already failed – aborting
how could i write it the write way?
or is it better to fill the previous command? tomcat state=stopped pattern={{instance}} args={{instance}}