Skip to content

Commit

Permalink
Host: Redirect stderr/out to a file
Browse files Browse the repository at this point in the history
If the output is ignored, it'll eventually block the process.
  • Loading branch information
skyjake committed Feb 2, 2012
1 parent e57bad4 commit bc63804
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions doomsday/host/doomsday-host
Expand Up @@ -144,6 +144,11 @@ def checkPid(pid):
return False


def todaysBuild():
now = time.localtime()
return str((now.tm_year - 2011)*365 + now.tm_yday)


class State:
def __init__(self):
self.lastRun = self.now()
Expand Down Expand Up @@ -196,7 +201,9 @@ class State:
args += ['-parse', cfgFn]
args += ['-noinput']
args += sv.options + commonOptions
args += ['-out', os.path.join(sv.runtime, time.strftime('doomsday-%Y%m%d-%H%M%S.out'))]

timestamp = '%s-' % todaysBuild() + time.strftime('%H%M%S')
args += ['-out', os.path.join(sv.runtime, 'doomsday-%s.out' % timestamp)]

# Join the -parse arguments.
i = args.index('-parse')
Expand All @@ -212,10 +219,13 @@ class State:
j += 1

try:
msg('PATH=' + os.getenv('PATH'))
msg('HOME=' + os.getenv('HOME'))
msg('Start options: ' + string.join(args, ' '))
po = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
outfile = file(os.path.join(sv.runtime, 'stdout-%s.log' % timestamp), 'wt')
po = subprocess.Popen(args, stdout=outfile, stderr=outfile)
pid = po.pid
time.sleep(1)
time.sleep(3)
if po.poll() is not None:
raise OSError('terminated')
self.pids[sv.port] = pid
Expand Down

0 comments on commit bc63804

Please sign in to comment.