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

Properly detect syncthing http server running #7

Closed
Nutomic opened this issue May 14, 2014 · 9 comments
Closed

Properly detect syncthing http server running #7

Nutomic opened this issue May 14, 2014 · 9 comments

Comments

@Nutomic
Copy link
Contributor

Nutomic commented May 14, 2014

Right now, I just reload the GUI every second until it returns http status 200. I think this should be done better. Some ideas:

  • somehow wait until syncthing port is bound
  • have a .startup file that is deleted (from syncthing binary) once the GUI is up
  • any other way?

@calmh: What do you think?

@jpjp
Copy link

jpjp commented May 14, 2014

How about monitoring .config/syncthing/ for changes to .idx.gz files? (or monitoring that directory for any changes at all)

@Nutomic
Copy link
Contributor Author

Nutomic commented May 14, 2014

I was just about to edit something like that in :P

I'm not sure what those files do, but I assume they are not directly tied to the web interface (rather to syncing, so when pause is added, this might break).

@calmh
Copy link
Member

calmh commented May 14, 2014

So, the index files are a cache of the state of the local repository: file metadata and hashes. When syncthing starts up it reads the indexes and compares the local repository to them. Files that have changed are rehashed, files that are no longer there are marked as deleted, etc.

When syncthing is up and running it will periodically save a new index, if there have been any changes (i.e. changes detected locally, or we synced something).

I actually think polling the GUI port until it responds is the cleanest way, or just reading stdout from syncthing and looking for the pattern "Starting web GUI on "...

Or a new log line could be added before https://github.com/calmh/syncthing/blob/master/cmd/syncthing/main.go#L274 if you want to be really sure that the webserver is listening, not just that it will be in a few clock cycles. Practically, I think you will need to be very fast indeed to notice the difference.

@Nutomic
Copy link
Contributor Author

Nutomic commented May 14, 2014

Okay so index files aren't the way to go for this.

I only read the syncthing output on shutdown right now, so I can't do that (and it doesn't feel good).

So I'll just poll the port (but without a full-blown browser running).

@calmh
Copy link
Member

calmh commented May 15, 2014

(/rest/version should be the most lightweight URL to poll repeatedly and the response is something you can know if it's correct, but really anything should work)

@Nutomic
Copy link
Contributor Author

Nutomic commented May 15, 2014

I just do a Head request and check for http status 200. I also stop polling after the first successful try.

@bsidhom
Copy link

bsidhom commented Jun 10, 2014

I don't know if this should be considered related or a distinct issue, but when the web UI port is manually changed and the server is reset (all through the integrated web UI), the UI is not found in the web view. Exiting the application at this point does not appear to close down the server either. I was able to view the UI using an external browser, but this may have been due to the browser cache storing old information.

@Nutomic
Copy link
Contributor Author

Nutomic commented Jun 10, 2014

The address is read from the config.xml on start. It should work if you restart the app (menu->exit and then open it again). I just noticed that you'll get the same problem if you change the API key and do a restart through the web GUI.

Feel free to make that a new issue, I'll have to think about how to avoid those problems properly.

@Nutomic
Copy link
Contributor Author

Nutomic commented Jun 10, 2014

I just noticed this is a problem that I will have to fix with #5. (Config changes show a notification starting from 0.4.0, and we use that to update the repos, nodes, gui address, and api key).

@syncthing syncthing locked and limited conversation to collaborators Nov 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants