Skip to content

Commit

Permalink
Merge pull request #410 from HubSpot/logfetch_endpoint
Browse files Browse the repository at this point in the history
Logfetch endpoint
  • Loading branch information
ssalinas committed Jan 20, 2015
2 parents c23b265 + 3bc67ca commit 08dd92e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions scripts/logfetch/live_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from singularity_request import get_json_response
import logfetch_base

DOWNLOAD_FILE_FORMAT = '{0}/sandbox/{1}/download'
DOWNLOAD_FILE_FORMAT = 'http://{0}:5051/files/download.json'
BROWSE_FOLDER_FORMAT = '{0}/sandbox/{1}/browse'

def download_live_logs(args):
Expand All @@ -20,20 +20,21 @@ def download_live_logs(args):
os.remove(f)
sys.stderr.write(colored('Downloading current live log files', 'blue') + '\n')
for task in tasks:
uri = DOWNLOAD_FILE_FORMAT.format(logfetch_base.base_uri(args), task)
metadata = files_json(args, task)
uri = DOWNLOAD_FILE_FORMAT.format(metadata['slaveHostname'])
service_log = '{0}-service.log'.format(task)
tail_log = '{0}-tail_of_finished_service.log'.format(task)
async_requests.append(
grequests.AsyncRequest('GET',uri ,
callback=generate_callback(uri, args.dest, service_log, args.chunk_size),
params={'path' : '{0}/service.log'.format(task)}
params={'path' : '{0}/{1}/service.log'.format(metadata['fullPathToRoot'], metadata['currentDirectory'])}
)
)
all_logs.append('{0}/{1}'.format(args.dest, service_log))
async_requests.append(
grequests.AsyncRequest('GET',uri ,
callback=generate_callback(uri, args.dest, tail_log, args.chunk_size),
params={'path' : '{0}/tail_of_finished_service.log'.format(task)}
params={'path' : '{0}/{1}/tail_of_finished_service.log'.format(metadata['fullPathToRoot'], metadata['currentDirectory'])}
)
)
all_logs.append('{0}/{1}'.format(args.dest, service_log))
Expand All @@ -42,7 +43,7 @@ def download_live_logs(args):
async_requests.append(
grequests.AsyncRequest('GET',uri ,
callback=generate_callback(uri, args.dest, logfile_name, args.chunk_size),
params={'path' : '{0}/logs/{1}'.format(task, log_file)}
params={'path' : '{0}/{1}/logs/{1}'.format(metadata['fullPathToRoot'], metadata['currentDirectory'], log_file)}
)
)
if logfile_name.endswith('.gz'):
Expand All @@ -59,6 +60,10 @@ def tasks_to_check(args):
else:
return logfetch_base.tasks_for_request(args)

def files_json(args, task):
uri = BROWSE_FOLDER_FORMAT.format(logfetch_base.base_uri(args), task)
return get_json_response(uri)

def logs_folder_files(args, task):
uri = BROWSE_FOLDER_FORMAT.format(logfetch_base.base_uri(args), task)
files_json = get_json_response(uri, {'path' : '{0}/logs'.format(task)})
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='singularity-logfetch',
version='0.0.6',
version='0.0.7',
description='Singularity log fetching and searching',
author="HubSpot",
author_email='[email protected]',
Expand Down

0 comments on commit 08dd92e

Please sign in to comment.