diff --git a/packages/console-app/config.yml b/packages/console-app/config.yml
index 150b1c4..85be7a6 100644
--- a/packages/console-app/config.yml
+++ b/packages/console-app/config.yml
@@ -22,20 +22,19 @@ system:
services:
app:
prefix: '/app'
- server: 'http://127.0.0.1:5999'
+ server: 'https://xbox.local'
wns:
- server: 'http://127.0.0.1:9473/api'
- webui: 'http://127.0.0.1:9473/webui'
+ server: 'https://xbox.local/dxos/wns/api'
+ webui: 'https://xbox.local/dxos/wns/webui'
signal:
- server: 'http://127.0.0.1:4000'
- api: 'http://127.0.0.1:4000'
+ server: 'wss://xbox.local/dxos/signal'
+ api: 'https://xbox.local/dxos/signal/'
ipfs:
- server: '/ip4/127.0.0.1/tcp/5001'
- gateway: '/ip4//127.0.0.1:8888/ipfs/'
- webui: 'http://127.0.0.1:5001/webui'
+ server: 'https://xbox.local/dxos/ipfs/api'
+ gateway: 'https://xbox.local/dxos/ipfs/gateway'
wellknown:
- endpoint: 'http://127.0.0.1:9000/.well-known/dxos'
+ endpoint: 'https://xbox.local/.well-known/dxos'
diff --git a/packages/console-app/src/containers/panels/wns/WNSLog.js b/packages/console-app/src/containers/panels/wns/WNSLog.js
index d0f40bb..9fcb485 100644
--- a/packages/console-app/src/containers/panels/wns/WNSLog.js
+++ b/packages/console-app/src/containers/panels/wns/WNSLog.js
@@ -14,12 +14,13 @@ import Log from '../../../components/Log';
const WNSLog = () => {
const { config } = useContext(ConsoleContext);
const data = useQueryStatusReducer(useQuery(WNS_LOG, { pollInterval: config.api.intervalLog }));
+ console.error(data);
if (!data) {
return null;
}
return (
-
+
);
};
diff --git a/packages/console-app/src/gql/wns_log.graphql b/packages/console-app/src/gql/wns_log.graphql
index ab5f741..4c80fdc 100644
--- a/packages/console-app/src/gql/wns_log.graphql
+++ b/packages/console-app/src/gql/wns_log.graphql
@@ -3,8 +3,8 @@
#
query {
- wns_log @client {
+ wns_log {
timestamp
- log
+ json
}
}
diff --git a/packages/console-server/config.yml b/packages/console-server/config.yml
index ac97bae..85be7a6 100644
--- a/packages/console-server/config.yml
+++ b/packages/console-server/config.yml
@@ -3,8 +3,6 @@
# NOTE: Set CONFIG_FILE to swap out this config file.
#
-# TODO(burdon): Set defaults.
-
app:
title: 'Console'
org': 'DxOS'
@@ -24,20 +22,19 @@ system:
services:
app:
prefix: '/app'
- server: 'http://127.0.0.1:5999'
+ server: 'https://xbox.local'
wns:
- server: 'https://node1.dxos.network/wns/api'
- webui: 'https://node1.dxos.network/wns/webui'
+ server: 'https://xbox.local/dxos/wns/api'
+ webui: 'https://xbox.local/dxos/wns/webui'
signal:
- server: 'http://127.0.0.1:4000'
- api: 'http://127.0.0.1:4000'
+ server: 'wss://xbox.local/dxos/signal'
+ api: 'https://xbox.local/dxos/signal/'
ipfs:
- server: '/ip4/127.0.0.1/tcp/5001'
- gateway: '/ip4//127.0.0.1:8888/ipfs/'
- webui: 'http://127.0.0.1:5001/webui'
+ server: 'https://xbox.local/dxos/ipfs/api'
+ gateway: 'https://xbox.local/dxos/ipfs/gateway'
wellknown:
- endpoint: 'http://127.0.0.1:9000/.well-known/dxos'
+ endpoint: 'https://xbox.local/.well-known/dxos'
diff --git a/packages/console-server/src/gql/api.graphql b/packages/console-server/src/gql/api.graphql
index 62780ad..542a323 100644
--- a/packages/console-server/src/gql/api.graphql
+++ b/packages/console-server/src/gql/api.graphql
@@ -8,33 +8,22 @@ type JSONResult {
json: String!
}
-type Result {
- timestamp: String!
- code: Int!
-}
-
-type Log {
- timestamp: String!
- log: [String]!
-}
-
#
# Schema
#
-type Mutation {
- action(command: String!): Result!
-}
-
type Query {
- system_status: SystemStatus!
+ app_swarm_log: JSONResult!
+ ipfs_log: JSONResult!
ipfs_status: JSONResult!
+ ipfs_swarm_log: JSONResult!
+ signal_status: JSONResult!
+ signal_swarm_log: JSONResult!
+ system_status: JSONResult!
wns_status: JSONResult!
- wns_records(type: String): JSONResult!
- wns_log: Log!
+ wns_log: JSONResult!
}
schema {
- mutation: Mutation
query: Query
}
diff --git a/packages/console-server/src/gql/system.graphql b/packages/console-server/src/gql/system.graphql
deleted file mode 100644
index 937ce42..0000000
--- a/packages/console-server/src/gql/system.graphql
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# Copyright 2020 DxOS.org
-#
-
-type SystemStatus {
- timestamp: String!
- json: String!
-}
diff --git a/packages/console-server/src/resolvers/index.js b/packages/console-server/src/resolvers/index.js
index d0fcd65..32288dd 100644
--- a/packages/console-server/src/resolvers/index.js
+++ b/packages/console-server/src/resolvers/index.js
@@ -7,6 +7,7 @@ import defaultsDeep from 'lodash.defaultsdeep';
import { ipfsResolvers } from './ipfs';
import { systemResolvers } from './system';
+import { logResolvers } from "./log";
const log = debug('dxos:console:server:resolvers');
@@ -19,14 +20,4 @@ export const resolvers = defaultsDeep({
// TODO(burdon): Auth.
// https://www.apollographql.com/docs/apollo-server/data/errors/#codes
- Mutation: {
- action: async (_, { command }) => {
- log(`WNS action: ${command}`);
-
- return {
- timestamp: new Date().toUTCString(),
- code: 0
- };
- }
- }
-}, ipfsResolvers, systemResolvers);
+}, ipfsResolvers, systemResolvers, logResolvers);
diff --git a/packages/console-server/src/resolvers/log.js b/packages/console-server/src/resolvers/log.js
new file mode 100644
index 0000000..a58693f
--- /dev/null
+++ b/packages/console-server/src/resolvers/log.js
@@ -0,0 +1,65 @@
+//
+// Copyright 2020 DxOS.org
+//
+
+import moment from 'moment';
+import pick from 'lodash.pick';
+import os from 'os';
+import si from 'systeminformation';
+import { spawnSync } from "child_process";
+
+class LogCache {
+ constructor(maxLines = 500) {
+ // Sets in JS iterate in insertion order.
+ this.buffer = new Set();
+ this.maxLines = maxLines;
+ }
+
+ append(lines) {
+ const added = [];
+ for (const line of lines) {
+ if (!this.buffer.has(line)) {
+ this.buffer.add(line);
+ added.push(line);
+ }
+ }
+
+ if (this.buffer.size > this.maxLines) {
+ this.buffer = new Set(Array.from(this.buffer).slice(parseInt(this.maxLines / 2)));
+ }
+
+ return added;
+ }
+}
+
+const _caches = new Map();
+const getLogCache = (name) => {
+ let cache = _caches.get(name);
+ if (!cache) {
+ cache = new LogCache();
+ _caches.set(name, cache);
+ }
+ return cache;
+}
+
+const getLogs = async (name, lines = 100) => {
+ const command = 'wire';
+ const args = ['service', 'logs', '--lines', lines, name];
+
+ const child = spawnSync(command, args, { encoding: 'utf8' });
+ const logLines = child.stdout.split(/\n/);
+ const cache = getLogCache(name);
+ return cache.append(logLines);
+};
+
+export const logResolvers = {
+ Query: {
+ wns_log: async () => {
+ const logs = await getLogs('wns-list');
+ return {
+ timestamp: new Date().toUTCString(),
+ json: JSON.stringify(logs)
+ };
+ }
+ }
+};
diff --git a/packages/console-server/src/server/main.js b/packages/console-server/src/server/main.js
index 073aeb6..8d7d22c 100644
--- a/packages/console-server/src/server/main.js
+++ b/packages/console-server/src/server/main.js
@@ -22,7 +22,6 @@ import SYSTEM_STATUS from '@dxos/console-app/src/gql/system_status.graphql';
import { resolvers } from '../resolvers';
import API_SCHEMA from '../gql/api.graphql';
-import SYSTEM_SCHEMA from '../gql/system.graphql';
const argv = yargs
.option('config', {
@@ -113,10 +112,7 @@ app.get(publicUrl, (req, res) => {
const server = new ApolloServer({
typeDefs: [
- API_SCHEMA,
- SYSTEM_SCHEMA
- // WNS_EXTENSIONS,
- // WNS_SCHEMA
+ API_SCHEMA
],
// https://www.apollographql.com/docs/graphql-tools/resolvers