java.restart-service.yml
1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
- hosts: java-{{ service }}
serial: "50%"
remote_user: root
vars:
yoho_services: ['gateway','message','sns','users']
yohobuy_services: ['activity','bigdata','brower','order','product','promotion','resources','risk','union','wechat']
uniq_services: ['uic']
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_patch: "yoho-erp-gateway"
when: service == "erpgateway"
- name: restart {{ deploy_path }}
shell: sh /home/master/{{ deploy_path }}/deploy/bin/killws.sh && sh /home/master/{{ deploy_path }}/deploy/bin/startws.sh
async: 60
- name: check service runtime
shell: ps -ef|grep java|grep {{ deploy_path }}|awk '{print $5}'
register: service_runtime
- name: print service uptime
debug: msg="Serivce last uptime is {{ service_runtime.stdout }}"