[WORKER] Fix for saving stats on initial UPDATE

The HAProxy statistics socket file will not exist on a new device,
so attempts to save the stats before a reload would fail.

Change-Id: Ib31509bb7d68424d63f41b1c3032f15a1ca786e2
This commit is contained in:
David Shrewsbury 2013-12-12 11:41:57 -05:00
parent 3fb0401679
commit d6388ca0e6
1 changed files with 7 additions and 1 deletions

View File

@ -39,7 +39,13 @@ class UbuntuServices(services_base.ServicesBase):
"""
Save current HAProxy totals for an expected restart.
"""
q = query.HAProxyQuery('/var/run/haproxy-stats.socket')
socket_file = '/var/run/haproxy-stats.socket'
# On a new device, the socket file won't exist.
if not os.path.exists(socket_file):
return
q = query.HAProxyQuery(socket_file)
results = q.get_bytes_out()
stats_file = cfg.CONF['worker:haproxy']['statsfile']