mirror of
https://github.com/unraid/api.git
synced 2026-01-16 21:50:18 -06:00
refactor: add bootTime/uptime to os/info
This commit is contained in:
@@ -25,6 +25,7 @@ const baseTypes = [gql`
|
||||
scalar JSON
|
||||
scalar Long
|
||||
scalar UUID
|
||||
scalar DateTime
|
||||
|
||||
directive @func(
|
||||
module: String
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import GraphQLJSON from 'graphql-type-json';
|
||||
import GraphQLLong from 'graphql-type-long';
|
||||
import GraphQLUUID from 'graphql-type-uuid';
|
||||
import { GraphQLDateTime } from 'graphql-iso-date';
|
||||
import { Query } from './query';
|
||||
import { Subscription } from './subscription';
|
||||
import { UserAccount } from './user-account';
|
||||
@@ -13,6 +14,7 @@ import { UserAccount } from './user-account';
|
||||
export const JSON = GraphQLJSON;
|
||||
export const Long = GraphQLLong;
|
||||
export const UUID = GraphQLUUID;
|
||||
export const DateTime = GraphQLDateTime;
|
||||
|
||||
export {
|
||||
Query,
|
||||
|
||||
@@ -3,4 +3,16 @@
|
||||
* Written by: Alexis Tyler
|
||||
*/
|
||||
|
||||
export default () => ({});
|
||||
import { readFileSync } from 'fs';
|
||||
|
||||
// Get uptime on boot and convert to date
|
||||
const bootTimestamp = (new Date().getTime()) - parseFloat(readFileSync('/proc/uptime', 'utf-8').split(' ')[0]);
|
||||
|
||||
export default () => ({
|
||||
os: {
|
||||
// Timestamp of when the server booted
|
||||
bootTime: bootTimestamp,
|
||||
// Milliseconds since the server booted
|
||||
uptime: new Date().getTime() - bootTimestamp
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,4 +14,5 @@ type Os {
|
||||
logofile: String
|
||||
serial: String
|
||||
build: String
|
||||
uptime: DateTime
|
||||
}
|
||||
10
package-lock.json
generated
10
package-lock.json
generated
@@ -5125,11 +5125,6 @@
|
||||
"type": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"daemonize-process": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/daemonize-process/-/daemonize-process-3.0.0.tgz",
|
||||
"integrity": "sha512-xydLk6LrHflrLTqcYBnPHtwFnAQR+lhP/OHHef6sQ9E0I0tR42xGV5y2qFd1DVJsUt/2pMQN7OSOVmmX+Cubhw=="
|
||||
},
|
||||
"dargs": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dargs/-/dargs-7.0.0.tgz",
|
||||
@@ -8040,6 +8035,11 @@
|
||||
"apollo-server-types": "^0.6.3"
|
||||
}
|
||||
},
|
||||
"graphql-iso-date": {
|
||||
"version": "3.6.1",
|
||||
"resolved": "https://registry.npmjs.org/graphql-iso-date/-/graphql-iso-date-3.6.1.tgz",
|
||||
"integrity": "sha512-AwFGIuYMJQXOEAgRlJlFL4H1ncFM8n8XmoVDTNypNOZyQ8LFDG2ppMFlsS862BSTCDcSUfHp8PD3/uJhv7t59Q=="
|
||||
},
|
||||
"graphql-subscriptions": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/graphql-subscriptions/-/graphql-subscriptions-1.1.0.tgz",
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
"globby": "^11.0.2",
|
||||
"graphql": "^15.5.0",
|
||||
"graphql-directive": "^0.2.1",
|
||||
"graphql-iso-date": "^3.6.1",
|
||||
"graphql-subscriptions-client": "OmgImAlexis/graphql-subscriptions-client#master",
|
||||
"graphql-tag": "^2.11.0",
|
||||
"graphql-type-json": "^0.3.2",
|
||||
|
||||
Reference in New Issue
Block a user