Skip to content

fix: exit webedit when port is already in use#21

Open
joeblew999 wants to merge 1 commit intoromshark:mainfrom
joeblew999:fix/webedit-port-exit-clean
Open

fix: exit webedit when port is already in use#21
joeblew999 wants to merge 1 commit intoromshark:mainfrom
joeblew999:fix/webedit-port-exit-clean

Conversation

@joeblew999
Copy link
Copy Markdown

Summary

Fixes #16

Previously, when the server port was already in use, toki webedit would log an error but continue running indefinitely, waiting for an interrupt signal. This was confusing as the UI wouldn't open but the process wouldn't exit.

Now the server uses a channel to signal startup errors back to the main goroutine, which properly exits with an error message when the port is unavailable.

Changes

  • Added serverErr channel to communicate server startup failures
  • Changed from blocking on interrupt signal only to select on both interrupt and server error
  • Returns proper error when port is in use instead of hanging

Test

# Start something on port 52000
python3 -m http.server 52000 &

# Try webedit - now exits with error instead of hanging
toki webedit -host :52000 -dontopen
# Output: [ERROR] server failed to start: listen tcp :52000: bind: address already in use

Previously, when the server port was already in use, toki webedit
would log an error but continue running indefinitely, waiting for
an interrupt signal. This was confusing as the UI wouldn't open
but the process wouldn't exit.

Now the server uses a channel to signal startup errors back to
the main goroutine, which properly exits with an error message
when the port is unavailable.

Fixes romshark#16
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.

webedit doesn't exit when port already in use

1 participant