-
Notifications
You must be signed in to change notification settings - Fork 86
Fix port replacement on creating new site from backup #944
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
Changes from all commits
b1e27c9
664e920
3488884
40ecb84
acc93cb
6fc2074
bb017a5
da18d9d
00db122
f6ee07c
c8b8a6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,7 @@ import { StoredToken } from 'src/lib/oauth'; | |||||||||
| import * as oauthClient from 'src/lib/oauth'; | ||||||||||
| import { createPassword } from 'src/lib/passwords'; | ||||||||||
| import { phpGetThemeDetails } from 'src/lib/php-get-theme-details'; | ||||||||||
| import { portFinder } from 'src/lib/port-finder'; | ||||||||||
| import { shellOpenExternalWrapper } from 'src/lib/shell-open-external-wrapper'; | ||||||||||
| import { sortSites } from 'src/lib/sort-sites'; | ||||||||||
| import { installSqliteIntegration, keepSqliteIntegrationUpdated } from 'src/lib/sqlite-versions'; | ||||||||||
|
|
@@ -161,11 +162,14 @@ export async function createSite( | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const port = await portFinder.getOpenPort(); | ||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are running website immidiatelly after creating it, so it's tiotale safe to define the port during setting up website. And I would say, there are even benefit of such approach, since we configure everything for our site in advance and have complete data for it and I don't see any benefit in postponning choosing port for it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that the port is assigned in site creation, should we remove tha code from Lines 81 to 82 in 00db122
Line 74 in 00db122
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about it, but:
But this my assumption is connected, but another topic, so in this PR I want to fix described issues and later cover that edge case as a separate PR, to not mix up everything. WDYT about my thoughts?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sejas btw, I have also assumption that this issue is related to what I am mentioning above. I will investigate it, but off the top of my head, the issue here is:
What I want to say is - maybe, during starting server, we should always take port from Thinking about it more, I believe that we should do complex fix, like I proposed above or something similar, to keep Studio more stable.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My concern is that in this PR we are adding another I understand the concern about a port being already busy, but currently the WordPress site will redirect to that port producing an unexpected behaviour. So I don't see harm on removing that code. We could create an issue to consider that edge case and "replacing" the url+port in the database and appdata. We don't need to try to fix that in this PR. Maybe the issue is an edge case that it's not worth implementing it and we could document it somewhere, or wait to see if any user reports it. There are other solutions, like displaying an alert if the port is busy.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, ok, let's go this way. I will create issues and I removed this: But I think it's nice to keep
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked my assumption and it indeed fails and we don't show any error in UI, just endless "Starting..." copy.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I didn't see the code or tested this case but I also think the port assignment should be sequential. Maybe we should release the port when the site is removed ? I thought that if it's not in appData then it could be free to use.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok!, It seems the releaseport is already in delete and not in stop as I thought. It's good to leave it 👌 Line 74 in 9b31ef9
|
||||||||||
|
|
||||||||||
| const details = { | ||||||||||
| id: crypto.randomUUID(), | ||||||||||
| name: siteName || nodePath.basename( path ), | ||||||||||
| path, | ||||||||||
| adminPassword: createPassword(), | ||||||||||
| port, | ||||||||||
| running: false, | ||||||||||
| phpVersion: DEFAULT_PHP_VERSION, | ||||||||||
| } as const; | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
It's redundant, since we are starting server in the previous step above https://github.com/Automattic/studio/blob/trunk/src/hooks/use-import-export.tsx#L134