#!/usr/bin/env node

/**
 * GitDB Server Global Executable
 * This file is the entry point when users run 'gitdb-server' globally
 */

const path = require('path');
const { spawn } = require('child_process');

const serverPath = path.join(__dirname, '../dist/server.js');
const child = spawn(process.execPath, [serverPath], { stdio: 'inherit' });
child.on('exit', code => process.exit(code));

process.on('SIGINT', () => {
  console.log('\nShutting down gitdb-server...');
  process.exit(0);
});

process.on('SIGTERM', () => {
  console.log('\nShutting down gitdb-server...');
  process.exit(0);
}); 