UNPKG

@electric-sql/cli

Version:

ElectricSQL command line interface (CLI).

41 lines 1.14 kB
import { Command } from "commander"; import { dockerCompose } from './docker-utils.js'; import { getConfig } from '../config.js'; function makeStopCommand() { return new Command("stop").description( "Stop the ElectricSQL sync service, and any optional PostgreSQL" ).option("-r --remove", "Also remove the containers and volumes").action(async (opts) => { stop({ config: getConfig(), remove: opts.remove }); }); } function stop(opts) { const config = opts.config; return new Promise((resolve) => { const env = { COMPOSE_PROFILES: "with-postgres" // Stop any PostgreSQL containers too }; let proc; if (opts.remove) { proc = dockerCompose("down", ["--volumes"], config.CONTAINER_NAME, env); } else { proc = dockerCompose("stop", [], config.CONTAINER_NAME, env); } proc.on("close", (code) => { if (code !== 0) { console.error("Failed to stop the ElectricSQL sync service."); process.exit(code ?? 1); } else { resolve(); } }); }); } export { makeStopCommand, stop }; //# sourceMappingURL=command-stop.js.map