# HG changeset patch # User drewp@bigasterisk.com # Date 1580884911 28800 # Node ID fe9cfc088a49bed85f8b54c6a1cba74cd0abdd4c # Parent e4d31cfa37f022f76ab9bd02c54855530ed498b9 consolidate debug page into ./index.html for now Ignore-this: 56775a500165c5c707238d99fbdb6739 diff -r e4d31cfa37f0 -r fe9cfc088a49 service/collector/Dockerfile --- a/service/collector/Dockerfile Tue Feb 04 17:07:05 2020 -0800 +++ b/service/collector/Dockerfile Tue Feb 04 22:41:51 2020 -0800 @@ -10,8 +10,7 @@ RUN pip3 install --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple -U 'https://github.com/drewp/cyclone/archive/python3.zip' COPY stubs ./stubs -COPY *.py req* *.ini ./ -COPY static ./static +COPY *.py *.html req* *.ini ./ EXPOSE 9072 diff -r e4d31cfa37f0 -r fe9cfc088a49 service/collector/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/service/collector/index.html Tue Feb 04 22:41:51 2020 -0800 @@ -0,0 +1,156 @@ + + + + collector + + + + + +

collector

+ +

See output for graph/home

+ + + + + diff -r e4d31cfa37f0 -r fe9cfc088a49 service/collector/sse_collector.py --- a/service/collector/sse_collector.py Tue Feb 04 17:07:05 2020 -0800 +++ b/service/collector/sse_collector.py Tue Feb 04 22:41:51 2020 -0800 @@ -31,7 +31,7 @@ from patchablegraph.patchsource import ReconnectingPatchSource -from sse_collector_config import config +from collector_config import config #SourceUri = NewType('SourceUri', URIRef) # doesn't work class SourceUri(URIRef): pass @@ -450,8 +450,7 @@ cyclone.web.Application( handlers=[ (r"/()", cyclone.web.StaticFileHandler, { - "path": "static", "default_filename": "index.html"}), - (r'/static/(.*)',cyclone.web.StaticFileHandler, {"path": "static"}), + "path": ".", "default_filename": "index.html"}), (r'/state', State), (r'/graph/', GraphList), (r'/graph/(.+)', PatchSink), diff -r e4d31cfa37f0 -r fe9cfc088a49 service/collector/static/index.html --- a/service/collector/static/index.html Tue Feb 04 17:07:05 2020 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ - - - - collector - - - - - - - - - - -

collector

- -

See output for graph/home

- - - - diff -r e4d31cfa37f0 -r fe9cfc088a49 service/collector/static/state.js --- a/service/collector/static/state.js Tue Feb 04 17:07:05 2020 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -import { LitElement, TemplateResult, html, css } from '/lib/lit-element/2.2.0/lit-element-custom.js'; - -class CollectorState extends LitElement { - static get properties() { - return { - latestState: { type: Object } - }; - } - firstUpdated() { - this.latestState = {graphClients: {}}; - this.refreshLoop(); - } - - refreshLoop() { - setTimeout(() => { - requestAnimationFrame(() => { - this.refresh(); - }); - }, 5000); - } - - refresh() { - fetch('state') - .then((response) => { - return response.json(); - }) - .then((newState) => { - this.latestState = newState; - this.refreshLoop(); - }); - } - - static get styles() { - return css` - :host { - display: inline-block; - border: 2px solid gray; - padding: 5px; - }`; - } - - render() { - const sourcesTable = (clients) => { - const clientRow = (client) => { - const d = client.reconnectedPatchSource; - const now = Date.now() / 1000; - const dispSec = (sec) => ( - Math.abs(sec) > now - 1 ? '--' : - Math.abs(sec) > 3600 ? - `${Math.round(sec/3600)} hr` : Math.abs(sec) > 60 ? - `${Math.round(sec/60)} min` : - `${Math.round(sec*10)/10} sec`); - return html` - - [browse] ${d.url} - ${d.fullGraphReceived} - ${d.patchesReceived} - ${dispSec(d.time.open - now)} - ${dispSec(d.time.fullGraph - d.time.open)} - ${dispSec(d.time.latestPatch - now)} - - `; - }; - - return html` - - - - - - - - - - - - - ${clients.map(clientRow)} - -
patch sourcefull graph recvpatches recvtime open (rel)time fullGraph (after open)time latest patch (rel)
- `; - }; - - const handlersTable = (handlers) => { - const handlerRow = (d) => { - return html` - - ${d.created} - ${d.ageHours} - ${d.streamId} - ${d.foafAgent} - ${d.userAgent} - - `; - }; - - return html` - - - - - - - - - - - - ${handlers.map(handlerRow)} - -
createdage hoursstreamfoaf agentuser agent
- `; - }; - - if (!this.latestState) { - return 'loading...'; - } - const d = this.latestState.graphClients; - return html` -
-

- Graph: ${d.statements ? d.statements.len : 0} statements -

- -

- Sources: - ${sourcesTable(d.clients || [])} -

- -

- Listening clients: - ${handlersTable(d.sseHandlers || [])} -

-
`; - } -} -customElements.define('collector-state', CollectorState);