Buckets:
| ; | |
| var __importDefault = (this && this.__importDefault) || function (mod) { | |
| return (mod && mod.__esModule) ? mod : { "default": mod }; | |
| }; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.KillOthers = void 0; | |
| const lodash_1 = __importDefault(require("lodash")); | |
| const operators_1 = require("rxjs/operators"); | |
| const command_1 = require("../command"); | |
| /** | |
| * Sends a SIGTERM signal to all commands when one of the commands exits with a matching condition. | |
| */ | |
| class KillOthers { | |
| logger; | |
| abortController; | |
| conditions; | |
| killSignal; | |
| constructor({ logger, abortController, conditions, killSignal, }) { | |
| this.logger = logger; | |
| this.abortController = abortController; | |
| this.conditions = lodash_1.default.castArray(conditions); | |
| this.killSignal = killSignal; | |
| } | |
| handle(commands) { | |
| const conditions = this.conditions.filter((condition) => condition === 'failure' || condition === 'success'); | |
| if (!conditions.length) { | |
| return { commands }; | |
| } | |
| const closeStates = commands.map((command) => command.close.pipe((0, operators_1.map)(({ exitCode }) => exitCode === 0 ? 'success' : 'failure'), (0, operators_1.filter)((state) => conditions.includes(state)))); | |
| closeStates.forEach((closeState) => closeState.subscribe(() => { | |
| this.abortController?.abort(); | |
| const killableCommands = commands.filter((command) => command_1.Command.canKill(command)); | |
| if (killableCommands.length) { | |
| this.logger.logGlobalEvent(`Sending ${this.killSignal || 'SIGTERM'} to other processes..`); | |
| killableCommands.forEach((command) => command.kill(this.killSignal)); | |
| } | |
| })); | |
| return { commands }; | |
| } | |
| } | |
| exports.KillOthers = KillOthers; | |
Xet Storage Details
- Size:
- 1.83 kB
- Xet hash:
- ac668dc88a244e585cd0b45d2fe25fb7e5b224edec283d6b3f0b8b8404bd1544
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.