redirector-cli
Version:
Global CLI tool for managing Redirector backend services with Docker Compose
64 lines • 2.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.restartCommand = restartCommand;
const logger_1 = require("../utils/logger");
const config_1 = require("../utils/config");
const docker_1 = require("../utils/docker");
async function restartCommand(options) {
try {
logger_1.Logger.header("Restarting Redirector Services");
const projectPath = process.cwd();
// Check if project is initialized
const isInitialized = await config_1.ConfigManager.isRedirectorProject(projectPath);
if (!isInitialized) {
logger_1.Logger.error("No Redirector project found in current directory");
logger_1.Logger.info("Run `redirector setup` first to initialize the project");
process.exit(1);
}
// Load configuration
const config = await config_1.ConfigManager.loadConfig(projectPath);
const docker = new docker_1.DockerManager(config, projectPath);
// Validate Docker
const dockerRunning = await config_1.ConfigManager.validateDockerRunning();
if (!dockerRunning) {
logger_1.Logger.error("Docker daemon is not running. Please start Docker first.");
process.exit(1);
}
// Pull images if requested
if (options.pull) {
await docker.pullImages();
}
// Restart services
await docker.restartServices();
// Show status
logger_1.Logger.newLine();
logger_1.Logger.subheader("Service Status:");
const containers = await docker.getStatus();
if (containers.length === 0) {
logger_1.Logger.warning("No containers found");
}
else {
containers.forEach((container) => {
const status = container.status.includes("running") ? "✓" : "✗";
logger_1.Logger.info(`${status} ${container.name}: ${container.status}`);
if (container.ports) {
logger_1.Logger.info(` Ports: ${container.ports}`);
}
});
}
logger_1.Logger.newLine();
logger_1.Logger.success("Services restarted successfully!");
logger_1.Logger.newLine();
logger_1.Logger.subheader("Access URLs:");
logger_1.Logger.list([
`Backend API: http://localhost:${config.backendPort}`,
`Health Check: http://localhost:${config.backendPort}/health`,
`PostgreSQL: localhost:${config.postgresPort}`,
]);
}
catch (error) {
logger_1.Logger.error(`Failed to restart services: ${error}`);
process.exit(1);
}
}
//# sourceMappingURL=restart.js.map