feat: enable os uptime

This commit is contained in:
Alexis Tyler
2020-12-13 00:38:40 +10:30
parent 1ee6e2393e
commit 7dcf87cf0b
4 changed files with 26 additions and 1 deletions
+1
View File
@@ -27,6 +27,7 @@ export * from './get-permissions';
export * from './get-plugins';
export * from './get-services';
export * from './get-unassigned-devices';
export * from './get-uptime';
export * from './get-users';
export * from './get-vars';
export * from './get-welcome';
+10 -1
View File
@@ -344,17 +344,26 @@ dee.on('*', async (data: { Type: string }) => {
dee.listen();
// This needs to be fixed to run from events
// @TODO: This needs to be fixed to run from events
setIntervalAsync(async () => {
// @todo: Create a system user for this
const user = usersState.findOne({ name: 'root' });
// Services
await run('services', 'UPDATED', {
moduleToRun: modules.getServices,
context: {
user
}
});
// OS uptime
await run('uptime', 'UPDATED', {
moduleToRun: modules.getUptime,
context: {
user
}
});
}, 1000);
export const graphql = {
@@ -51,6 +51,9 @@ export const Subscription = {
unassignedDevices: {
...createSubscription('devices/unassigned')
},
uptime: {
...createSubscription('uptime')
},
users: {
...createSubscription('users')
},
@@ -0,0 +1,12 @@
type Query {
uptime: Uptime @func(module: "getUptime")
}
type Subscription {
uptime: Uptime
}
type Uptime {
milliseconds: Int!
timestamp: String!
}