UNPKG

redis-smq-common

Version:

Provides essential components and utilities shared across RedisSMQ packages.

55 lines 2.64 kB
#!/usr/bin/env node "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const build_redis_js_1 = require("../src/redis-server/build-redis.js"); const index_js_1 = require("../src/redis-server/index.js"); const redis_binary_js_1 = require("../src/redis-server/redis-binary.js"); commander_1.program .command('redis') .description('Handle Redis server tasks') .option('--download-binary', 'Download Redis binary') .option('--build-from-source', 'Build Redis binary') .option('--start-server', 'Start Redis server') .option('--port <number>', 'Redis server port', '6379') .action((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (options = {}) { if (options.downloadBinary) { console.log('Downloading Redis binary...'); yield (0, redis_binary_js_1.downloadPrebuiltBinary)(); console.log('Done.'); return; } if (options.buildFromSource) { console.log('Building Redis binary...'); yield (0, build_redis_js_1.buildRedisBinary)(); console.log('Done.'); return; } if (options.startServer) { const port = parseInt(options.port || '6379', 10); const shutdown = () => __awaiter(void 0, void 0, void 0, function* () { console.log('\nShutting down Redis server...'); yield server.shutdown(); process.exit(0); }); console.log(`Starting Redis server on ${port}...`); const server = new index_js_1.RedisServer(); process.on('SIGINT', shutdown); process.on('SIGTERM', shutdown); yield server.start(port); console.log('Redis server is running. Press Ctrl+C to stop.'); return; } console.error('No Redis task specified. Use --download-binary, --build-from-source, or --start-server'); })); commander_1.program.parse(process.argv); //# sourceMappingURL=cli.js.map