From c13c4d0b28fc7f8a752eadb00b6ed79e47b5baa4 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Fri, 29 Jun 2018 23:01:22 +0200 Subject: [PATCH] Ensure we purge all nginx configs of an app --- src/reverseproxy.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/reverseproxy.js b/src/reverseproxy.js index 995b22e3b..b3ccc9719 100644 --- a/src/reverseproxy.js +++ b/src/reverseproxy.js @@ -44,6 +44,7 @@ var acme = require('./cert/acme.js'), path = require('path'), paths = require('./paths.js'), platform = require('./platform.js'), + rimraf = require('rimraf'), safe = require('safetydance'), shell = require('./shell.js'), users = require('./users.js'), @@ -408,19 +409,12 @@ function unconfigureApp(app, callback) { assert.strictEqual(typeof app, 'object'); assert.strictEqual(typeof callback, 'function'); - var nginxConfigFilenames = [ path.join(paths.NGINX_APPCONFIG_DIR, `${app.id}.conf`) ]; - app.alternateDomains.forEach(function (d) { - var fqdn = (d.subdomain ? (d.subdomain + '.') : '') + d.domain; - nginxConfigFilenames.push(path.join(paths.NGINX_APPCONFIG_DIR, `${app.id}-redirect-${fqdn}.conf`)) - }); + // we use globbing to find all nginx configs for an app + rimraf(path.join(paths.NGINX_APPCONFIG_DIR, `${app.id}*.conf`), function (error) { + if (error) debug('Error removing nginx configurations of "%s":', app.fqdn, error); - nginxConfigFilenames.forEach(function (filename) { - if (!safe.fs.unlinkSync(filename)) { - if (safe.error.code !== 'ENOENT') debug('Error removing nginx configuration of "%s" at %s: %s', app.fqdn, filename, safe.error.message); - } + reload(callback); }); - - reload(callback); } function renewAll(auditSource, callback) {