-
Notifications
You must be signed in to change notification settings - Fork 27
feat(server): share process across multiple instances #159
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
feat(server): share process across multiple instances #159
Conversation
Add a lock file mechanism to coordinate a single server process among multiple Neovim clients. Track ownership and active clients in opencode-server.lock to ensure the process persists until the last instance closes. Additionally, implement URI encoding for API queries.
|
This PR is generated by AI with I think this code is ok |
Add logic to tests/unit/util_spec.lua to handle year transitions in date formatting. The assertions now check the year of the timestamp to determine if the year should be present in the output string.
Replace the `owner` field in the lock file with `server_pid` to explicitly track the background process. Update `unregister_client` to return this PID and remove client promotion logic.
nvim returns non-zero exit codes when error messages are printed, even for expected errors in error handling tests. Changed test runner to check for actual '[31mFail.*||' patterns in output instead.
568d1a6 to
f948664
Compare
|
Thanks for the PR this looks interesting, I will play with it a little bit |
|
If you need to modify code, feel free to contact me! |
|
This repository is great |
sudo-tee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really great feature for the plugin, and it looks stable from the tests I did.
I did add some little nitpicking , but otherwise this looks good
|
Seems like this will also have the benefit of correctly attaching new sessions to the CWD if that changes within the Neovim instance (e.g. using the |
Move health check logic from OpencodeServer.try_existing_server to a new static OpencodeApiClient.check_health method using promises.
|
I have modified the code based on the comment, I think now maybe it is ok? |
Theoretically yes, but I'm wondering if anyone would actually change the CWD with |
|
Oh, I found a problem, sometime plugin will create more than one opencode, I will figure out the reason |
Replace file lock-based server discovery with direct health checks. Adds configurable server port and improves shutdown handling with cross-platform support and graceful process termination.
…ction Add double-check mechanism to prevent killing server when new clients register during shutdown, and extract process management utilities.
|
Shit, I will create a new pr to achieve this |
Description:
Problem
The current file lock mechanism for preventing multiple opencode server instances is unstable:
Solution
Replace the dual-file lock mechanism with a simpler, more reliable approach:
Changes
lua/opencode/opencode_server.lua- Remove flock, blocking shutdown, fixed port spawnlua/opencode/server_job.lua- Health check first, port binding as mutexlua/opencode/config.lua- Add server.port configtests/unit/server_job_spec.lua- Update tests