UNPKG

gitdb-database

Version:

A production-ready CLI tool for managing a NoSQL database using GitHub repositories as storage

46 lines (38 loc) 1.2 kB
#!/usr/bin/env node /** * GitDB Global CLI Executable * This file is the main entry point when users run 'gitdb' globally */ const path = require('path'); const { spawn } = require('child_process'); const args = process.argv.slice(2); if (args[0] === 'shell') { const shellPath = path.join(__dirname, '../dist/shell.js'); const child = spawn(process.execPath, [shellPath], { stdio: 'inherit' }); child.on('exit', code => process.exit(code)); } else if (args[0] === 'server') { const serverPath = path.join(__dirname, '../dist/server.js'); const child = spawn(process.execPath, [serverPath], { stdio: 'inherit' }); child.on('exit', code => process.exit(code)); } else { // Show help console.log(` GitDB v1.0.0 Usage: gitdb server - Start the GitDB server gitdb shell - Start the GitDB shell gitdb help - Show this help Examples: gitdb server - Start server on http://localhost:7896 gitdb shell - Start interactive shell `); } // Handle graceful shutdown process.on('SIGINT', () => { console.log(`\nShutting down gitdb...`); process.exit(0); }); process.on('SIGTERM', () => { console.log(`\nShutting down gitdb...`); process.exit(0); });