Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.