Skip to content

Instantly share code, notes, and snippets.

@mihaitodor
Created August 7, 2020 22:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihaitodor/0e3d80a1a66da033939a5064eb573597 to your computer and use it in GitHub Desktop.
Save mihaitodor/0e3d80a1a66da033939a5064eb573597 to your computer and use it in GitHub Desktop.
Hubspot/Singularity `extraScript` config hack for adding links in the menu to instances of a given service
<script>
fetch('/singularity/api/tasks/ids/request/{{ Environment }}_{{ Service }}')
.then(response => response.json()).then((taskIDs) => {
Object.values(taskIDs.healthy).forEach(function(task) {
fetch('/singularity/api/tasks/task/' + task.id)
.then(response => response.json()).then((taskInfo) => {
let host = taskInfo.taskId.host.replace(/_/g, '-');
let port = taskInfo.mesosTask.container.docker.portMappings[0].hostPort;
let a = document.createElement('a');
a.textContent = '{{ Service }} at ' + host + ':' + port;
a.href = 'http://' + host + ':' + port;
let li = document.createElement('li');
li.appendChild(a);
document.getElementsByClassName('navbar-brand')[0].nextSibling.appendChild(li);
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment