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

[v3] Add port flag to dev command #3429

Merged
merged 4 commits into from May 2, 2024

Conversation

abichinger
Copy link

@abichinger abichinger commented Apr 26, 2024

Description

This PR adds the following flag to the dev command:

  • vport: The vite dev server port, default: 9245

And adds support for the environment variable WAILS_VITE_PORT

server.strictport is set to exit if the specified port is already in use.

Fixes #3379

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

The following commands have been executed inside a new project:

wails3 dev                                   # Port: 9245
wails3 dev -port 3333                        # Port: 3333
WAILS_VITE_PORT=3333 wails3 dev             # Port: 3333
wails3 task dev                              # Port: 9245
wails3 task dev VITE_PORT=3333               # Port: 3333
WAILS_VITE_PORT=3333 wails3 task dev        # Port: 3333
WAILS_VITE_PORT=3333 wails3 dev -port=2222  # Port: 2222

Executing wails3 dev twice triggered the following error message:

  ERROR   listen tcp 127.0.0.1:9245: bind: address already in use
  • Windows
  • macOS
  • Linux

Test Configuration

# System
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Name         | Manjaro Linux                                                                                                  |
| Version      | Unknown                                                                                                        |
| ID           | manjaro                                                                                                        |
| Branding     |                                                                                                                |
| Platform     | linux                                                                                                          |
| Architecture | amd64                                                                                                          |
| CPU          | AMD Ryzen 5 3600 6-Core Processor                                                                              |
| GPU 1        | Navi 10 [Radeon RX 5600 OEM/5600 XT / 5700/5700 XT] (Advanced Micro Devices, Inc. [AMD/ATI]) - Driver: amdgpu  |
| Memory       | 32GB                                                                                                           |
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Build Environment
┌─────────────────────────────────────────────────────────────────────────────────────────────────┐
| Wails CLI      | v3.0.0-alpha.4                                                                 |
| Go Version     | go1.22.0                                                                       |
| Revision       | 1b288a0a1a37c849a4edc22430b372e8469308ec                                       |
| Modified       | true                                                                           |
| -buildmode     | exe                                                                            |
| -compiler      | gc                                                                             |
| CGO_CFLAGS     |                                                                                |
| CGO_CPPFLAGS   |                                                                                |
| CGO_CXXFLAGS   |                                                                                |
| CGO_ENABLED    | 1                                                                              |
| CGO_LDFLAGS    |                                                                                |
| DefaultGODEBUG | httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1 |
| GOAMD64        | v1                                                                             |
| GOARCH         | amd64                                                                          |
| GOOS           | linux                                                                          |
| vcs            | git                                                                            |
| vcs.modified   | true                                                                           |
| vcs.revision   | 1b288a0a1a37c849a4edc22430b372e8469308ec                                       |
| vcs.time       | 2024-04-23T14:32:21Z                                                           |
└─────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────┐
| gcc        | 13.2.1-5     |
| libgtk-3   | 1:3.24.41-1  |
| libwebkit  | 2.42.5-2     |
| npm        | 10.5.0       |
| pkg-config | 2.1.0-2      |
└─ * - Optional Dependency ─┘

# Diagnosis
 SUCCESS  Your system is ready for Wails development!

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@leaanthony leaanthony merged commit 2255af1 into wailsapp:v3-alpha May 2, 2024
4 checks passed
@leaanthony
Copy link
Member

Thanks for this!

leaanthony added a commit that referenced this pull request May 5, 2024
* Add `port` flag to dev command, ...

Add support for environment variable WAILS_VITE_PORT

* Check if port is already in use

* Update changelog

---------

Co-authored-by: Lea Anthony <[email protected]>
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.

None yet

2 participants