1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- const _ = require('lodash')
- const Promise = require('bluebird')
- const getos = Promise.promisify(require('getos'))
- const os = require('os')
- const filesize = require('filesize')
- const path = require('path')
- /* global WIKI */
- const dbTypes = {
- mysql: 'MySQL / MariaDB',
- postgres: 'PostgreSQL',
- sqlite: 'SQLite',
- mssql: 'MS SQL Server'
- }
- module.exports = {
- Query: {
- async system() { return {} }
- },
- Mutation: {
- async system() { return {} }
- },
- SystemQuery: {
- async info(obj, args, context, info) {
- 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()}`
- }
- console.info(WIKI.db.knex.client)
- return {
- configFile: path.join(process.cwd(), 'config.yml'),
- currentVersion: WIKI.version,
- dbType: _.get(dbTypes, WIKI.config.db.type, 'Unknown DB'),
- dbVersion: _.get(WIKI.db, 'knex.client.version', 'Unknown version'),
- dbHost: WIKI.config.db.host,
- latestVersion: WIKI.version, // TODO
- latestVersionReleaseDate: new Date(), // TODO
- operatingSystem: osLabel,
- 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'),
- redisHost: WIKI.redis.options.host
- }
- }
- },
- SystemMutation: { }
- }
|