Skip to content

Commit

Permalink
Use 1.5GB limit on storage check
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Aug 27, 2023
1 parent dbb172a commit 5417c08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "domcloud-bridge",
"version": "0.27.1",
"version": "0.28.0",
"description": "Deployment runner for DOM Cloud",
"main": "app.js",
"engines": {
Expand Down
20 changes: 16 additions & 4 deletions sudoutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ switch (cli.args.shift()) {
setTimeout(() => {
// just in case
if (!sudo.killed)
sudo.kill();
sudo.kill();
}, 1000 * 60 * 60).unref();
break;
case 'SHELL_INTERACTIVE':
Expand Down Expand Up @@ -230,16 +230,29 @@ switch (cli.args.shift()) {
})).to(env.SHELLCHECK_TMP);
exit(0);
case 'SHELL_TEST':
var isDfFull = function (df) {
var r = /([\d\.]+[GMK]?)\s+\d+%/g;
var m;
while (m = r.exec(df)) {
if (!m) return false;
var size = parseFloat(m[1].slice(0, -1));
var unit = m[1].slice(-1);
size = size * (unit === 'T' ? 1024 * 1024 : unit === 'G' ? 1024 : unit === 'M' ? 1 : 0.001);
if (size < 1536) {
return true;
}
}
return false;
}
var nginx = exec(`${env.NGINX_BIN} -t`, { silent: true });
var fpmlist = ls(env.PHPFPM_REMILIST).filter((f) => f.match(/php\d\d/));
var fpmpaths = fpmlist.map((f) => env.PHPFPM_REMILOC.replace('$', f));
var fpms = fpmpaths.map((f) => exec(`${f} -t`, { silent: true }));
var iptables = exec(`${env.IPTABLES_LOAD} -t ${env.IPTABLES_PATH}`, { silent: true });
var ip6tables = exec(`${env.IP6TABLES_LOAD} -t ${env.IP6TABLES_PATH}`, { silent: true });
var storage = exec(`df -h | grep ^/dev`, { silent: true });
var storagefull = /\b(9[5-9]|100)%/.test(storage.stdout);
var inodes = exec(`df -i | grep ^/dev`, { silent: true });
var inodesfull = /\b(9[5-9]|100)%/.test(inodes.stdout);
var storagefull = isDfFull(storage.stdout);
var chkmem = exec(`free -h`, { silent: true });
var chkcpu = exec(`uptime`, { silent: true })

Expand All @@ -256,7 +269,6 @@ switch (cli.args.shift()) {
iptables: iptables.code,
ip6tables: ip6tables.code,
storage: storagefull ? 1 : 0,
inodes: inodesfull ? 1 : 0,
},
logs: {
cpuinfo: chkcpu.stdout.trim().split('\n'),
Expand Down

0 comments on commit 5417c08

Please sign in to comment.