38 lines
958 B
TypeScript
38 lines
958 B
TypeScript
/**
|
|
* Main exports and CLI entry point for GitOps
|
|
*/
|
|
|
|
export { GitopsApp } from './classes/gitopsapp.ts';
|
|
export { logger } from './logging.ts';
|
|
|
|
import { GitopsApp } from './classes/gitopsapp.ts';
|
|
import { logger } from './logging.ts';
|
|
|
|
export async function runCli(): Promise<void> {
|
|
const args = Deno.args;
|
|
const command = args[0] || 'server';
|
|
|
|
switch (command) {
|
|
case 'server': {
|
|
const port = parseInt(Deno.env.get('GITOPS_PORT') || '3000', 10);
|
|
const app = new GitopsApp();
|
|
await app.start(port);
|
|
|
|
// Handle graceful shutdown
|
|
const shutdown = async () => {
|
|
logger.info('Shutting down...');
|
|
await app.stop();
|
|
Deno.exit(0);
|
|
};
|
|
|
|
Deno.addSignalListener('SIGINT', shutdown);
|
|
Deno.addSignalListener('SIGTERM', shutdown);
|
|
break;
|
|
}
|
|
default:
|
|
logger.error(`Unknown command: ${command}`);
|
|
logger.info('Usage: gitops [server]');
|
|
Deno.exit(1);
|
|
}
|
|
}
|