UNPKG

iop

Version:
55 lines 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.requiresZeroDowntimeDeployment = requiresZeroDowntimeDeployment; exports.getDeploymentStrategy = getDeploymentStrategy; exports.getServiceProxyPort = getServiceProxyPort; exports.isInfrastructurePort = isInfrastructurePort; /** * Determines if a service requires zero-downtime deployment based on its characteristics */ function requiresZeroDowntimeDeployment(service) { // Only services with proxy configuration get zero-downtime deployment // All other services (including those with health_check or exposed ports) get stop-start return Boolean(service.proxy); } /** * Determines deployment strategy for a service */ function getDeploymentStrategy(service) { return requiresZeroDowntimeDeployment(service) ? 'zero-downtime' : 'stop-start'; } /** * Gets the effective port for proxy configuration */ function getServiceProxyPort(service) { // Explicit proxy port takes precedence if (service.proxy?.app_port) { return service.proxy.app_port; } // Infer from exposed ports if (service.ports) { for (const port of service.ports) { if (!port.includes(':') && !isNaN(parseInt(port))) { return parseInt(port); // "3000" -> 3000 } if (port.startsWith(':') && !isNaN(parseInt(port.substring(1)))) { return parseInt(port.substring(1)); // ":3000" -> 3000 } } } return undefined; } /** * Checks if a port configuration indicates infrastructure service */ function isInfrastructurePort(port) { // Common infrastructure ports that are typically mapped, not exposed const infraPorts = ['5432', '3306', '6379', '27017', '9200', '5672']; if (port.includes(':')) { const parts = port.split(':'); const containerPort = parts[parts.length - 1]; return infraPorts.includes(containerPort); } return infraPorts.includes(port); } //# sourceMappingURL=service-utils.js.map