redis-smq-common
Version:
RedisSMQ Common Library provides many components that are mainly used by RedisSMQ and RedisSMQ Monitor.
44 lines • 1.7 kB
JavaScript
import { program } from 'commander';
import { buildRedisBinary } from '../src/redis-server/build-redis.js';
import { RedisServer } from '../src/redis-server/index.js';
import { downloadPrebuiltBinary } from '../src/redis-server/redis-binary.js';
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(async (options = {}) => {
if (options.downloadBinary) {
console.log('Downloading Redis binary...');
await downloadPrebuiltBinary();
console.log('Done.');
return;
}
if (options.buildFromSource) {
console.log('Building Redis binary...');
await buildRedisBinary();
console.log('Done.');
return;
}
if (options.startServer) {
const port = parseInt(options.port || '6379', 10);
const shutdown = async () => {
console.log('\nShutting down Redis server...');
await server.shutdown();
process.exit(0);
};
console.log(`Starting Redis server on ${port}...`);
const server = new RedisServer();
process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);
await 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');
});
program.parse(process.argv);
//# sourceMappingURL=cli.js.map