Skip to content

Commit

Permalink
Add ability to specify stdout and stderr files for local_job_service
Browse files Browse the repository at this point in the history
  • Loading branch information
kennknowles committed May 22, 2020
1 parent efbafba commit 46252f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 1 addition & 2 deletions runners/portability/java/build.gradle
Expand Up @@ -152,8 +152,7 @@ task ulrValidatesRunnerTests(type: Test) {
classpath = configurations.validatesRunner
systemProperty "beamTestPipelineOptions", JsonOutput.toJson([
"--runner=TestUniversalRunner",
"--localJobServicePortFile=/Users/klk/tmp/port_52881"
//"--localJobServicePortFile=${localJobServicePortFile}"
"--localJobServicePortFile=${localJobServicePortFile}"
])
testClassesDirs = files(project(":sdks:java:core").sourceSets.test.output.classesDirs)
useJUnit {
Expand Down
Expand Up @@ -65,6 +65,12 @@ def run(argv):
action='store_true',
help='Start the server up as a background process.'
' Will fail if pid_file already exists, unless --stop is also specified.')
parser.add_argument(
'--stderr_file',
help='Where to write stderr for background job service (if not specified, merged with stdout).')
parser.add_argument(
'--stdout_file',
help='Where to write stdout for background job service.')
parser.add_argument(
'--stop',
action='store_true',
Expand Down Expand Up @@ -99,11 +105,23 @@ def run(argv):
options.port_file = os.path.splitext(options.pid_file)[0] + '.port'
argv.append('--port_file')
argv.append(options.port_file)

if not options.stdout_file:
raise RuntimeError('--stdout_file must be specified with --background')
stdout_dest = open(options.stdout_file, mode='w')

if options.stderr_file:
stderr_dest=open(options.stderr_file, mode='w')
else:
stderr_dest=subprocess.STDOUT

subprocess.Popen([
sys.executable,
'-m',
'apache_beam.runners.portability.local_job_service_main'
] + argv)
] + argv,
stderr=stderr_dest,
stdout=stdout_dest)
print('Waiting for server to start up...')
while not os.path.exists(options.port_file):
time.sleep(.1)
Expand Down

0 comments on commit 46252f5

Please sign in to comment.