Hi Team ,
I am planning to do up gradation some app and for so we need to restart the java application once my other app is upgraded and for so , i have written a playbook.
can someone please help to write a play for starting the application . ( Start command i have grep from "ps -ef | grep java | grep newrelic )
[root@chnr1-book4flights4extapi-1 ~]# ps -ef | grep java | grep newrelic
lmny+ 8328 1 0 Jul09 ? 06:10:13 java -server -Xms1g -Xmx3g -d64 -Dnewrelic.config.distributed_tracing.enabled=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:+UseG1GC -Dct.ctconfig.consul.server=http://consul-ctconfig.cltp.com:8500 -Dct.common.servertype=book4flights4extapi -Dapp.context.path=book -Dspring.profiles.active=prod,book4flights4extapi -javaagent:/opt/cal/newrelic/newrelic.jar -jar /opt/cal/latest.war
Note** - letter in bold letter is start command.
Command to start the application is :- nohup java -server -Xms1g -Xmx3g -d64 -Dnewrelic.config.distributed_tracing.enabled=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:+UseG1GC -Dct.ctconfig.consul.server=http://consul-ctconfig.cltp.com:8500 -Dct.common.servertype=book4flights4extapi -Dapp.context.path=book -Dspring.profiles.active=prod,book4flights4extapi -javaagent:/opt/cal/newrelic/newrelic.jar -jar /opt/cal/latest.war &
Playbook:
tasks:
- name: Create a directory to take the backup of old new relic configuration
file:
path: /opt/cal/newrelic/newrelic_old
state: directory
mode: ‘0755’
- name: To take the backup of all the existing new configuration of newrelic
shell: “mv /opt/cal/newrelic/newrelic* /opt/cal/newrelic/newrelic_old/”
- name: " To update the new relic version of jar "
copy:
src: /home/raviranjan/newrelic/{{ item }}
dest: /opt/cal/newrelic/
with_items:
- newrelic.jar
- newrelic.yml
- name: To get the running process for newrelic
shell: "ps -ef | grep java | grep newrelic | awk ‘{print $2}’ | xargs kill -9 "
register: running_process
- name: To start the application
any guidance would be much appreciated