Skip to content

Commit

Permalink
Merge pull request #34 from ethereum-optimism/nick/remove-server
Browse files Browse the repository at this point in the history
removes server
  • Loading branch information
nitaliano authored Dec 17, 2024
2 parents 19443fb + f2716d5 commit 2f0d148
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions packages/cli/src/commands/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,14 @@ import type {AppProps} from 'pastel';
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
import {useInput} from 'ink';
import {DbProvider} from '@/db/dbContext';
import {useEffect, useState} from 'react';
import {startServer} from '@/server/startServer';
import {useState} from 'react';
import {Spinner} from '@inkjs/ui';

export const queryClient = new QueryClient();

export default function App({Component, commandProps}: AppProps) {
const [isExiting, setIsExiting] = useState(false);

useEffect(() => {
let server: Awaited<ReturnType<typeof startServer>> | undefined;

// Start the server and store the reference
startServer()
.then(s => {
server = s;
})
.catch(err => {
console.error('Failed to start server:', err);
});

// Cleanup function
return () => {
if (server) {
setIsExiting(true);
// Use the callback to ensure the server is fully closed
server.close(err => {
if (err) {
console.error('Error while closing server:', err);
}
process.exit();
});
}
};
}, []);

useInput((input, key) => {
if (input === 'c' && key.ctrl) {
Expand Down

0 comments on commit 2f0d148

Please sign in to comment.