-
Notifications
You must be signed in to change notification settings - Fork 360
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
Comments
How about monitoring .config/syncthing/ for changes to .idx.gz files? (or monitoring that directory for any changes at all) |
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). |
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. |
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). |
( |
I just do a Head request and check for http status 200. I also stop polling after the first successful try. |
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. |
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. |
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). |
Right now, I just reload the GUI every second until it returns http status 200. I think this should be done better. Some ideas:
.startup
file that is deleted (from syncthing binary) once the GUI is up@calmh: What do you think?
The text was updated successfully, but these errors were encountered: