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
#
#productservice1    start/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.

Reply via email to