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

Don't start birdseye if it's already running #7

Closed
alexmojaki opened this issue Mar 27, 2018 · 11 comments
Closed

Don't start birdseye if it's already running #7

alexmojaki opened this issue Mar 27, 2018 · 11 comments
Labels
bug Something isn't working
Milestone

Comments

@alexmojaki
Copy link
Collaborator

If birdseye is running outside of the extension, it fails to start because the port is already taken.

@Almenon
Copy link
Owner

Almenon commented Mar 27, 2018

wierd - when i run two birdseye's on the same port they both work. Maybe it is a OS-specific thing? What OS are you using?

@Almenon Almenon added the bug Something isn't working label Mar 27, 2018
@alexmojaki
Copy link
Collaborator Author

I'm using Mac, and that's normal behaviour on Linux too. I don't see how it could work otherwise - if two processes use the same port, how do you make sure a client talks to the right one?

@Almenon
Copy link
Owner

Almenon commented Mar 27, 2018

if two processes use the same port, how do you make sure a client talks to the right one?

No clue but windows seems to think it's okay :/

I have a ubuntu VM so I can reproduce the problem on there.

@Almenon
Copy link
Owner

Almenon commented Mar 30, 2018

I reproduced the problem in my VM.

simple solution to this: run birdseye in vscode under a different port. Let's say 7778, not sure if the exact number matters or not.

benefits: dead simple and easy. No need to find cross-platform way of detecting if birdseye is running.

drawbacks: if you are really unlucky you might happen to run birdseye using the same port vscode uses at the same time as running birdseye vscode.

Thoughts?

@Almenon
Copy link
Owner

Almenon commented Mar 30, 2018

oh wait, it looks like you expose a environment variable to check if its running

    if not os.environ.get('BIRDSEYE_SERVER_RUNNING'):

https://github.com/alexmojaki/birdseye/blob/1a9aaf8b55a04f200f01a8db7b3d0aee56251dfb/tests/test_interface.py#L49

In that case I just need to skip launching birdseye if that environment variable is present. Maybe display a info message to user telling them that birdseye is already running.

Checking for a environment variable in javascript is super easy, not even any imports required.

console.log(process.env.BIRDSEYE_SERVER_RUNNING)

@Almenon Almenon added this to the v0.0.3 milestone Mar 30, 2018
@Almenon
Copy link
Owner

Almenon commented Mar 30, 2018

Nevermind, that is just a travis setting.

https://github.com/alexmojaki/birdseye/blob/8f2d00299e9ae4ec84ea6b7c9f2b8dc082e08bbf/misc/travis_test.sh

Back to my original question, i guess - launch vscode birdseye under different port?

@alexmojaki
Copy link
Collaborator Author

Yes, it's just a travis setting.

You need to:

  1. Allow the user to configure which port birdseye runs on.
  2. When the user requests to show birdseye, make an HTTP request to localhost:
  3. If the request fails completely, there's no process running there, so run your birdseye.
  4. If the request succeeds, check the content for some defining feature like the text "Bird's Eye".
  5. If the content is there, don't do anything, you're good to go. Display the browser panel.
  6. If the content is not there, show an error message complaining that something else is running on .

@Almenon
Copy link
Owner

Almenon commented Mar 30, 2018

Allow the user to configure which port birdseye runs on.

Already done :)

If the request fails completely, there's no process running there, so run your birdseye.
If the request succeeds, check the content for some defining feature like the text "Bird's Eye".

It sounds a lot easier to just change the default port.
Now that I fixed #8 the worst case scenario is that a user happens to use the same port for something else, in which case they see the error and they can just change the port.

@Almenon
Copy link
Owner

Almenon commented Mar 30, 2018

Reopening in case of further discussion

@Almenon Almenon reopened this Mar 30, 2018
@alexmojaki
Copy link
Collaborator Author

You don't have to reopen issues just in case, it's possible to discuss on closed issues :)

My problem with changing the default port is that users may sometimes decide they'd like to open birdseye in a browser. Ideally this should work effortlessly without requiring anyone to look through documentation or configuration, which they might never think to do. They could solve the problem by running another server themselves, but it's likely they won't think to do that if or even know how if their only experience with birdseye is through this plugin (which will hopefully be the case sometimes). Plus this plugin is meant to make using birdseye as convenient as possible. Finally, birdseye should hopefully be usable by complete beginners to programming to help them learn, and for them any usability problem such as asking them to start a server is significantly magnified.

@Almenon
Copy link
Owner

Almenon commented Mar 31, 2018

I don't think it's likely that a user would open vscode's birdseye in a browser. If they are using the VSCode extension they would look at the preview. Using a birdseye extension for vscode would be kind of pointless if you did not use vscode.

I've opened a FAQ issue (see #9) in case users do run into this.

@Almenon Almenon closed this as completed Mar 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants