Skip to content

Commit

Permalink
clean domain w nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Feb 18, 2024
1 parent a3fe28d commit 712000e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.43.1",
"version": "0.43.2",
"description": "Deployment runner for DOM Cloud",
"main": "app.js",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/executor/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export default async function runConfig(config, domain, writer, sandbox = false)
await virtExec("delete-domain", value, {
user,
});
await spawnSudoUtil('PHPFPM_CLEAN', domaindata['ID']);
await spawnSudoUtil('CLEAN_DOMAIN', [domaindata['ID'], domain]);
// no need to do other stuff
return;
default:
Expand Down
22 changes: 15 additions & 7 deletions sudoutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,28 @@ switch (cli.args.shift()) {
cnf = cnf.replace(/^subjectAltName=DNS.+\n/gm, '');
ShellString(cnf).to(env.OPENSSL_OUT);
exit(0);
case 'PHPFPM_CLEAN':
arg = cli.args.shift();
case 'CLEAN_DOMAIN':
const id = cli.args.shift();
const domain = cli.args.shift();
var fpmlist = ls(env.PHPFPM_REMILIST).filter((f) => f.match(/php\d\d/));
var cleaned = '';
var fpmcleaned = '', nginxcleaned = '';
for (const f of fpmlist) {
var p = `${env.PHPFPM_REMICONF.replace('$', f)}/${arg}.conf`;
var p = `${env.PHPFPM_REMICONF.replace('$', f)}/${id}.conf`;
if (existsSync(p)) {
rm(p);
cleaned = f;
fpmcleaned = f;
break;
}
}
if (cleaned) {
exec(`systemctl restart ${cleaned}-php-fpm`, { silent: true })
if (existsSync(env.NGINX_PATH.replace('$', domain))) {
rm(p);
nginxcleaned = '1';
}
if (fpmcleaned) {
exec(`systemctl restart ${fpmcleaned}-php-fpm`)
}
if (nginxcleaned) {
exec(`${env.NGINX_BIN} -s reload`);
}
exit(0);
case 'SHELL_KILL':
Expand Down

0 comments on commit 712000e

Please sign in to comment.