-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add watcher on dev
command to restart server on code changes
#95
base: main
Are you sure you want to change the base?
Conversation
2f16ed5
to
0749e98
Compare
Also added a flag to disable the watcher
0749e98
to
5e9f807
Compare
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; | ||
} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Also added a flag to disable the watcher