Commit b61ceceb authored by Big Bad Waffle's avatar Big Bad Waffle

free memory and start of db download

parent ab312baa
const fs = require('fs');
const util = require('util');
const clientScp = require('scp2').scp;
const clientScp = require('scp2');
const clientSsh = require('node-ssh');
const clone = require('../../src/server/misc/clone.js');
......
......@@ -4,7 +4,7 @@ let client = require('./client');
let startup = {
init: async function (cmd, pars) {
if (['uptime'].indexOf(cmd) > -1)
if (['uptime', 'mem'].indexOf(cmd) > -1)
await client.init(pars);
await this[cmd](pars);
......@@ -12,6 +12,23 @@ let startup = {
process.exit();
},
mem: async function (serverName) {
let output = await client.execCommands([
'free -m'
]);
output = output
.split('\n')
[1]
.split(' ')
.filter(f => f.length);
const total = ~~output[1] + ~~output[2];
const percentage = ~~((~~output[1] / total) * 100);
console.log(`${output[1]}mb / ${total}mb (${percentage}% Used)`);
},
uptime: async function (serverName) {
let output = await client.execCommands([
'forever list --no-colors'
......@@ -32,7 +49,13 @@ let startup = {
].map((m, i) => output[i] + m).join(' '));
},
getLog: async function (serverName) {
db: async function (serverName) {
const targetFilename = '../../data/storage.db';
await client.downloadFile(serverName, '/opt/stagecoach/apps/isleward/current/data/storage.db', targetFilename);
},
log: async function (serverName) {
const targetFilename = `./downloads/${serverName}Log.log`;
await client.downloadFile(serverName, '.forever/isleward.log', targetFilename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment