Skip to content
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

You no longer need to press ctrl-c to exit if you say no to a new port #1887

Merged
merged 2 commits into from
Jan 6, 2023

Conversation

lfdebrux
Copy link
Member

@lfdebrux lfdebrux commented Jan 4, 2023

This PR refactors the code around finding an available port. We now run portScanner only once, when the dev server is started.

This fixes bug #462 (doesn't exit if you say no to a new port), as the prompt to the user and process.exit(0) take place outside of nodemon. This change also means we can remove the code saving the port number to a file.

@lfdebrux lfdebrux requested review from joelanman and BenSurgisonGDS and removed request for joelanman January 4, 2023 15:37
@lfdebrux lfdebrux force-pushed the ldeb-refactor-find-available-port branch 2 times, most recently from 82ad5ff to c469384 Compare January 4, 2023 15:56
@lfdebrux lfdebrux changed the title Fix #462 You no longer need to press ctrl-c to exit if you say no to a new port Jan 4, 2023
@lfdebrux lfdebrux force-pushed the ldeb-refactor-find-available-port branch from c469384 to 1cfde8a Compare January 4, 2023 15:57
@lfdebrux
Copy link
Member Author

lfdebrux commented Jan 4, 2023

There is one downside to this approach; changing the port number in app/config.json will now need a manual restart (the app will restart, but not use the new port number). However, that seems like a fairly unusual use case?

@lfdebrux lfdebrux force-pushed the ldeb-refactor-find-available-port branch 2 times, most recently from 31ffde8 to e3d4354 Compare January 4, 2023 18:08
Copy link
Contributor

@BenSurgisonGDS BenSurgisonGDS left a comment

Choose a reason for hiding this comment

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

I really like how you have tidied this up, particularly separating the dev-server code into a new file !

@lfdebrux
Copy link
Member Author

lfdebrux commented Jan 5, 2023

Thanks @BenSurgisonGDS! I've decided to split those changes into a separate PR, #1890, would you mind approving that?

@joelanman
Copy link
Contributor

this sounds very cool! Reviewing now...

@lfdebrux lfdebrux force-pushed the ldeb-refactor-find-available-port branch 3 times, most recently from 8c12b17 to b6cf313 Compare January 5, 2023 12:04
@@ -48,7 +47,8 @@ function generateAssetsSync ({ verbose } = {}) {

function clean () {
// doesn't clean extensions.scss, should it?
del.sync(['public/**', '.port.tmp', portTmpFile])
// TODO: These files are deprecated, remove this line in v14?
del.sync(['public/**', '.port.tmp', '.tmp/port.tmp'])
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we still need to delete the port files?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just in case the files are still around for some reason. It's not strictly necessary, just being neat.

@lfdebrux lfdebrux force-pushed the ldeb-refactor-find-available-port branch from b6cf313 to 03f8989 Compare January 5, 2023 12:07
Copy link
Contributor

@joelanman joelanman left a comment

Choose a reason for hiding this comment

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

looks good thanks! Not sure if we want to merge for the next release or not @nataliecarey ?

Argument `app` is never used.
This fixes #462, as the `process.exit(0)` is no longer done within the
`nodemon` process. It also means we're not running portScanner every time
the kit restarts, and we can remove the code saving the port number to a
file.

Note changing the port number in `app/config.json` will now require a
manual restart.
@BenSurgisonGDS BenSurgisonGDS force-pushed the ldeb-refactor-find-available-port branch from 03f8989 to e3c47cd Compare January 6, 2023 12:18
@BenSurgisonGDS BenSurgisonGDS merged commit d1c244c into main Jan 6, 2023
@BenSurgisonGDS BenSurgisonGDS deleted the ldeb-refactor-find-available-port branch January 6, 2023 14:56
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.

3 participants