Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle errors in tcollector related to failure to spawn collectors.
Change-Id: Ia27a4b528eac99e5d4f2ddc35c503d470eeaee37
Reviewed-on: https://review.stumble.net/11428
Reviewed-by: Dave Barr <barr@stumbleupon.com>
Tested-by: Benoit Sigoure <tsuna@stumbleupon.com>
Reviewed-by: Benoit Sigoure <tsuna@stumbleupon.com>
  • Loading branch information
Manuel Amador (Rudd-O) authored and tsuna committed Apr 24, 2012
1 parent ecfe699 commit 8ea1f96
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tcollector.py
Expand Up @@ -993,9 +993,23 @@ def spawn_collector(col):
# FIXME: do custom integration of Python scripts into memory/threads
# if re.search('\.py$', col.name) is not None:
# ... load the py module directly instead of using a subprocess ...
col.lastspawn = int(time.time())
col.proc = subprocess.Popen(col.filename, stdout=subprocess.PIPE,
try:
col.proc = subprocess.Popen(col.filename, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError, e:
if e.errno == 13:
LOG.error('failed to spawn collector %s: permission denied' %
col.filename)
return
elif e.errno == 2:
LOG.error('failed to spawn collector %s: no such file or directory' %
col.filename)
else:
raise
# the following line needs to move below this line because it is used in
# other logic and it makes no sense to update the last spawn time if the
# collector didn't actually spam
col.lastspawn = int(time.time())
set_nonblocking(col.proc.stdout.fileno())
set_nonblocking(col.proc.stderr.fileno())
if col.proc.pid > 0:
Expand Down

0 comments on commit 8ea1f96

Please sign in to comment.