[ansible-project] How to execute a backend java program?

2016-09-20 Thread
Hi, 
  I use ansible 2.0.0. and I want start a java web program which use spring 
boot and compile as a jar file, but it always don't work.
  I can execute "nohup java -jar xxx.jar &" on the target machine (the 
target machine is centos 7),but when I execute through ansible, it don't 
work.
my playbook is 
- hosts: testservers
  remote_user: root
  tasks:  
   - name: start product
 shell: chdir=/app nohup java -jar /app/product.jar &
 

I think all the method I can , for example, make a .sh file in the target 
machine, the sh file is
#!/bin/bash
java -jar /app/product.jar > /dev/null 2>&1
and I execute the sh file , it can start .
and the playbook is
shell: chdir=/app nohup ./startproduct.sh &
and I execute the playbook,
the product.jar can not be started yet.

and then I add it to service, the file is
#!/bin/bash
#
#productservice1start/stop product1
#
# chkconfig: 12345 80 90
# description: start/stop product1
#
### BEGIN INIT INFO
# Description: start/stop product1
### END INIT INFO

function start_product()
{
  nohup java -jar /app/product.jar > /dev/null 2>&1 &
}

function stop_product()
{
ps -ef | grep /app/product.jar | grep -v grep | awk '{print $2}' | 
xargs kill -9
}

case "$1" in
start)
start_product
;;

stop)
stop_product
;;

restart)
stop_product
start_product
;;
*)
echo "Usage : start | stop | restart"
;;
esac

and I execute the service in target machine, it work!
but I execute it in ansible playbook, it don't work!
service: name=productservice state=started

and I try add
async:45
poll: 0

the playbook still can not start the java program.

I can use playbook kill a process, start tomcat, but can't use it to start 
a java program( a website, a jar file)

 anybody can help me?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/591d0d84-93c8-4811-9ce8-f1003fd7e76b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] I can't execute java program

2016-09-27 Thread
Hi, 
   May I ask for execute java program with ansible?
   I execute a java program (spring boot project, a jar package for java 
web site)
  ansible ofbiz1 -m shell -a "chdir=/opt/CassEC-OrderSupports nohup java 
-jar  product.jar &", it echo success ,but in fact,it do nothing! the java 
program is not been started!
  I'm very sure that I can execute nohup java -jar  product.jar & in the 
machine directly, I can start the java program.

  and I try use this command , 
ansible ofbiz1 -m shell -a "chdir=/opt/CassEC-OrderSupports nohup 
/usr/java/jdk1.8.0_74/java -jar  product.jar &",
as I prefer the java direction, it work!
 
   Can anybody tell me why? and how can I use java -jar direct with ansible?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/93a1408f-18ab-43b8-8b29-90328899dea1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.