2018-03-18 04:34:32 +00:00
|
|
|
const _ = require('lodash')
|
2018-05-06 21:33:41 +00:00
|
|
|
const Promise = require('bluebird')
|
|
|
|
const getos = Promise.promisify(require('getos'))
|
2018-03-18 04:34:32 +00:00
|
|
|
const os = require('os')
|
|
|
|
const filesize = require('filesize')
|
2018-05-06 21:33:41 +00:00
|
|
|
const path = require('path')
|
2018-03-18 04:34:32 +00:00
|
|
|
|
|
|
|
/* global WIKI */
|
|
|
|
|
2018-05-06 21:33:41 +00:00
|
|
|
const dbTypes = {
|
|
|
|
mysql: 'MySQL / MariaDB',
|
|
|
|
postgres: 'PostgreSQL',
|
2018-05-19 20:40:07 +00:00
|
|
|
sqlite: 'SQLite',
|
|
|
|
mssql: 'MS SQL Server'
|
2018-05-06 21:33:41 +00:00
|
|
|
}
|
|
|
|
|
2018-03-18 04:34:32 +00:00
|
|
|
module.exports = {
|
|
|
|
Query: {
|
|
|
|
async system() { return {} }
|
|
|
|
},
|
|
|
|
Mutation: {
|
|
|
|
async system() { return {} }
|
|
|
|
},
|
|
|
|
SystemQuery: {
|
|
|
|
async info(obj, args, context, info) {
|
2018-05-06 21:33:41 +00:00
|
|
|
let osLabel = `${os.type()} (${os.platform()}) ${os.release()} ${os.arch()}`
|
|
|
|
if (os.platform() === 'linux') {
|
|
|
|
const osInfo = await getos()
|
|
|
|
osLabel = `${os.type()} - ${osInfo.dist} (${osInfo.codename || os.platform()}) ${osInfo.release || os.release()} ${os.arch()}`
|
|
|
|
}
|
|
|
|
|
2018-03-18 04:34:32 +00:00
|
|
|
return {
|
2018-05-06 21:33:41 +00:00
|
|
|
configFile: path.join(process.cwd(), 'config.yml'),
|
2018-03-18 04:34:32 +00:00
|
|
|
currentVersion: WIKI.version,
|
2018-05-06 21:33:41 +00:00
|
|
|
dbType: _.get(dbTypes, WIKI.config.db.type, 'Unknown DB'),
|
2018-05-19 20:40:07 +00:00
|
|
|
dbVersion: _.get(WIKI.db, 'knex.client.version', 'Unknown version'),
|
|
|
|
dbHost: WIKI.config.db.host,
|
2018-03-18 04:34:32 +00:00
|
|
|
latestVersion: WIKI.version, // TODO
|
|
|
|
latestVersionReleaseDate: new Date(), // TODO
|
2018-05-06 21:33:41 +00:00
|
|
|
operatingSystem: osLabel,
|
2018-03-18 04:34:32 +00:00
|
|
|
hostname: os.hostname(),
|
|
|
|
cpuCores: os.cpus().length,
|
|
|
|
ramTotal: filesize(os.totalmem()),
|
|
|
|
workingDirectory: process.cwd(),
|
|
|
|
nodeVersion: process.version.substr(1),
|
|
|
|
redisVersion: WIKI.redis.serverInfo.redis_version,
|
|
|
|
redisUsedRAM: WIKI.redis.serverInfo.used_memory_human,
|
|
|
|
redisTotalRAM: _.get(WIKI.redis.serverInfo, 'total_system_memory_human', 'N/A'),
|
2018-05-06 21:33:41 +00:00
|
|
|
redisHost: WIKI.redis.options.host
|
2018-03-18 04:34:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
SystemMutation: { }
|
|
|
|
}
|