Authored by root

java重启时间检查

... ... @@ -5,10 +5,12 @@
shell: sh /home/master/{{ deploy_path }}/deploy/bin/killws.sh && sh /home/master/{{ deploy_path }}/deploy/bin/startws.sh
async: 90
# 获取服务启动时间(ts)
- name: check service runtime
raw: date -d "`ps -eo lstart,etime,cmd | grep gateway|grep -Ev 'grep|ansible|python'|awk '{print substr($0,1,24)}'`" +%s
register: service_runtime
# 获取服务器当前系统时间(ts)
- name: system current time
shell: date +%s
register: current_time
... ... @@ -20,6 +22,7 @@
- "Current system time is: {{ lookup('pipe','date -d @'+current_time.stdout) }}"
- "interval is: {{ current_time.stdout|int - service_runtime.stdout|int }}"
# 服务启动时间与系统时间间隔超过60秒则标记为重启失败
- name: check restart status
fail:
msg: "System current time and service startup time error exceeds 60 seconds, interval is {{ current_time.stdout|int - service_runtime.stdout|int }} !"
... ...