feat(appstore): add service volumes and published ports
This commit is contained in:
@@ -133,6 +133,45 @@ export class ExternalGatewayManager {
|
||||
}
|
||||
|
||||
await this.syncDomains();
|
||||
await this.syncServiceRoutes();
|
||||
}
|
||||
|
||||
public async syncServiceRoutes(): Promise<void> {
|
||||
const services = this.database.getAllServices()
|
||||
.filter((service) => service.domain && service.status === 'running');
|
||||
const activeHostnames = new Set(services.map((service) => service.domain!));
|
||||
|
||||
for (const service of services) {
|
||||
try {
|
||||
await this.syncServiceRoute(service);
|
||||
} catch (error) {
|
||||
logger.warn(`Failed to sync external gateway route for ${service.domain}: ${getErrorMessage(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
await this.deleteStaleServiceRoutes(activeHostnames);
|
||||
}
|
||||
|
||||
private async deleteStaleServiceRoutes(activeHostnamesArg: Set<string>): Promise<void> {
|
||||
const records = await this.getGatewayDnsRecords();
|
||||
const staleRecordsByHostname = new Map<string, IGatewayDnsRecord>();
|
||||
|
||||
for (const record of records) {
|
||||
if (!record.hostname || activeHostnamesArg.has(record.hostname)) continue;
|
||||
if (!record.routeId && !record.appId && !record.serviceName) continue;
|
||||
staleRecordsByHostname.set(record.hostname, record);
|
||||
}
|
||||
|
||||
for (const record of staleRecordsByHostname.values()) {
|
||||
try {
|
||||
await this.deleteServiceRoute({
|
||||
name: record.serviceName || record.appId,
|
||||
domain: record.hostname,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.warn(`Failed to delete stale external gateway route for ${record.hostname}: ${getErrorMessage(error)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async isConfigured(): Promise<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user