diff --git a/src/addons.js b/src/addons.js index bf18455ef..18435b1a8 100644 --- a/src/addons.js +++ b/src/addons.js @@ -114,7 +114,7 @@ var RMAPPDIR_CMD = path.join(__dirname, 'scripts/rmappdir.sh'); function debugApp(app, args) { assert(!app || typeof app === 'object'); - var prefix = app ? (app.location || 'naked_domain') : '(no app)'; + var prefix = app ? config.appFqdn(app) : '(no app)'; debug(prefix + ' ' + util.format.apply(util, Array.prototype.slice.call(arguments, 1))); } @@ -645,9 +645,10 @@ function setupRedis(app, options, callback) { } const tag = infra.images.redis.tag, redisName = 'redis-' + app.id; + const label = config.appFqdn(app); // note that we do not add appId label because this interferes with the stop/start app logic const cmd = `docker run --restart=always -d --name=${redisName} \ - --label=location=${app.location} \ + --label=location=${label} \ --net cloudron \ --net-alias ${redisName} \ -m ${memoryLimit/2} \ diff --git a/src/apphealthmonitor.js b/src/apphealthmonitor.js index d1c961c57..7cb038035 100644 --- a/src/apphealthmonitor.js +++ b/src/apphealthmonitor.js @@ -5,6 +5,7 @@ var appdb = require('./appdb.js'), assert = require('assert'), async = require('async'), DatabaseError = require('./databaseerror.js'), + config = require('./config.js'), debug = require('debug')('box:apphealthmonitor'), docker = require('./docker.js').connection, mailer = require('./mailer.js'), @@ -25,7 +26,7 @@ var gDockerEventStream = null; function debugApp(app) { assert(!app || typeof app === 'object'); - var prefix = app ? (app.location || 'naked_domain') : '(no app)'; + var prefix = app ? config.appFqdn(app) : '(no app)'; var manifestAppId = app ? app.manifest.id : ''; var id = app ? app.id : ''; diff --git a/src/apps.js b/src/apps.js index a6b7ae941..c7b7befce 100644 --- a/src/apps.js +++ b/src/apps.js @@ -1121,13 +1121,13 @@ function restoreInstalledApps(callback) { if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error)); async.map(apps, function (app, iteratorDone) { - debug('marking %s for restore', app.location || app.id); + debug('marking %s for restore', config.appFqdn(app)); backups.getByAppIdPaged(1, 1, app.id, function (error, results) { var restoreConfig = !error && results.length ? { backupId: results[0].id, backupFormat: results[0].format } : null; appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_RESTORE, { restoreConfig: restoreConfig, oldConfig: null }, function (error) { - if (error) debug('did not mark %s for restore', app.location || app.id, error); + if (error) debug('did not mark %s for restore', config.appFqdn(app), error); iteratorDone(); // always succeed }); @@ -1143,10 +1143,10 @@ function configureInstalledApps(callback) { if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error)); async.map(apps, function (app, iteratorDone) { - debug('marking %s for reconfigure', app.location || app.id); + debug('marking %s for reconfigure', config.appFqdn(app)); appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_CONFIGURE, { oldConfig: null }, function (error) { - if (error) debug('did not mark %s for reconfigure', app.location || app.id, error); + if (error) debug('did not mark %s for reconfigure', config.appFqdn(app), error); iteratorDone(); // always succeed }); diff --git a/src/backups.js b/src/backups.js index 7cf8dab1d..a783d6066 100644 --- a/src/backups.js +++ b/src/backups.js @@ -704,7 +704,7 @@ function backupApp(app, callback) { const timestamp = (new Date()).toISOString().replace(/[T.]/g, '-').replace(/[:Z]/g,''); safe.fs.unlinkSync(paths.BACKUP_LOG_FILE); // start fresh log file - progress.set(progress.BACKUP, 10, 'Backing up ' + (app.altDomain || app.location)); + progress.set(progress.BACKUP, 10, 'Backing up ' + (app.altDomain || config.appFqdn(app))); backupAppWithTimestamp(app, timestamp, function (error) { progress.set(progress.BACKUP, 100, error ? error.message : ''); diff --git a/src/certificates.js b/src/certificates.js index 11759c4e3..59468c0b1 100644 --- a/src/certificates.js +++ b/src/certificates.js @@ -239,7 +239,7 @@ function renewAll(auditSource, callback) { } // reconfigure and reload nginx. this is required for the case where we got a renewed cert after fallback - var configureFunc = app.location === config.adminLocation() ? + var configureFunc = config.appFqdn(app) === config.adminFqdn() ? nginx.configureAdmin.bind(null, certFilePath, keyFilePath, constants.NGINX_ADMIN_CONFIG_FILE_NAME, config.adminFqdn()) : nginx.configureApp.bind(null, app, certFilePath, keyFilePath); diff --git a/src/cloudron.js b/src/cloudron.js index 01e098700..aa4b95fb8 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -892,7 +892,7 @@ function refreshDNS(callback) { // do not change state of installing apps since apptask will error if dns record already exists if (app.installationState !== appdb.ISTATE_INSTALLED) return callback(); - domains.upsertDNSRecords(app.location, 'A', [ ip ], callback); + domains.upsertDNSRecords(config.appFqdn(app), 'A', [ ip ], callback); }, function (error) { if (error) return callback(error); diff --git a/src/docker.js b/src/docker.js index e415aba5c..c8d566f13 100644 --- a/src/docker.js +++ b/src/docker.js @@ -51,7 +51,7 @@ var addons = require('./addons.js'), function debugApp(app, args) { assert(!app || typeof app === 'object'); - var prefix = app ? (app.location || '(bare)') : '(no app)'; + var prefix = app ? config.appFqdn(app) : '(no app)'; debug(prefix + ' ' + util.format.apply(util, Array.prototype.slice.call(arguments, 1))); } @@ -186,7 +186,7 @@ function createSubcontainer(app, name, cmd, options, callback) { '/run': {} }, Labels: { - 'location': app.location, + 'fqdn': config.appFqdn(app), 'appId': app.id, 'isSubcontainer': String(!isAppContainer) }, diff --git a/src/taskmanager.js b/src/taskmanager.js index a7b81f5df..fea215812 100644 --- a/src/taskmanager.js +++ b/src/taskmanager.js @@ -16,6 +16,7 @@ var appdb = require('./appdb.js'), assert = require('assert'), async = require('async'), child_process = require('child_process'), + config = require('./config.js'), debug = require('debug')('box:taskmanager'), locker = require('./locker.js'), sendFailureLogs = require('./logcollector.js').sendFailureLogs, @@ -47,7 +48,7 @@ function resumeTasks(callback) { if (app.installationState === appdb.ISTATE_ERROR) return; - debug('Creating process for %s (%s) with state %s', app.location, app.id, app.installationState); + debug('Creating process for %s (%s) with state %s', config.appFqdn(app), app.id, app.installationState); restartAppTask(app.id, NOOP_CALLBACK); // restart because the auto-installer could have queued up tasks already });