Skip to content

Conversation

@GAllen98
Copy link
Contributor

Also added a flag to disable the watcher

@GAllen98 GAllen98 force-pushed the add-watcher-to-restart-server-on-code-changes branch from 2f16ed5 to 0749e98 Compare February 18, 2025 14:31
Also added a flag to disable the watcher
@GAllen98 GAllen98 force-pushed the add-watcher-to-restart-server-on-code-changes branch from 0749e98 to 5e9f807 Compare February 18, 2025 14:34
Comment on lines +171 to +181
async function restartServer(
server: Server<typeof IncomingMessage, typeof ServerResponse>,
deployedUrl: string,
serverPort: number,
): Promise<Server<typeof IncomingMessage, typeof ServerResponse>> {
server.close();
const { spec } = await fetchAndValidateSpec(deployedUrl);
const newServer = await startUIServer(API_CONFIG, spec);
await open(`http://localhost:${serverPort}`);
return newServer;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the way to do it almost for sure, you need to hot reload the route which is serving the spec not restart the entire server (unless that doesn't work for some reason)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all that logic is inside startUIServer() so I don't see how I could do that in a straightforward way.
I could try and break everything down and restructure it for that to work, or even fetch the spec inside the GET /api/config route every time it gets called but I don't think it's worth it for either case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the open() call may not be necessary but I couldn't find a way to reload ui components so I just opened a new instance

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opening and closing the server is gonna be ultra slow and terrible devx, I think its worth tweaking whatever needs to be tweaked to fix this problem properly

@bh2smith
Copy link
Contributor

Closing as stale.

@bh2smith bh2smith closed this Mar 20, 2025
@bh2smith bh2smith deleted the add-watcher-to-restart-server-on-code-changes branch March 20, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants