java.restart-service.yml 1.35 KB
- hosts: java-{{ service }}
  serial: "50%"
  remote_user: root
  vars:
    yoho_services: ['gateway','message','sns','users','social']
    yohobuy_services: ['activity','bigdata','brower','order','product','promotion','resources','risk','union','wechat']
    uniq_services: ['uic','platform-cms','ufo-platform','ufo-fore']
  become: true
  become_method: sudo
  become_user: master

  tasks:
  - name: match yoho deploy path
    set_fact:
      deploy_path: yoho-{{ service }}
    when: service in yoho_services

  - name: match yohobuy deploy path
    set_fact:
      deploy_path: yohobuy-{{ service }}
    when: service in yohobuy_services

  - name: match uniq deploy path
    set_fact:
      deploy_path: "{{ service }}"
    when: service in uniq_services

  - name: match erpgateway deploy path
    set_fact:
      deploy_path: "yoho-erp-gateway"
    when: service == "erpgateway"

  - import_role:
      name: java.restart
#  - name: restart {{ deploy_path }}
#    shell: sh /home/master/{{ deploy_path }}/deploy/bin/killws.sh && sh /home/master/{{ deploy_path }}/deploy/bin/startws.sh
#    async: 120
#
#  - name: check service runtime
#    shell: ps -ef|grep java|grep {{ deploy_path }}|grep -v grep|awk '{print $5}'
#    register: service_runtime
#
#  - name: print service uptime
#    debug: msg="Serivce {{ deploy_path }} last uptime is {{ service_runtime.stdout }}"