-
Notifications
You must be signed in to change notification settings - Fork 402
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
Update docs for debugging server plugins #1370
Conversation
Newest code from mickmister has been published to preview environment for Git SHA 055a148 |
1 similar comment
Newest code from mickmister has been published to preview environment for Git SHA 055a148 |
If we want to debug the |
make attach-headless | ||
``` | ||
|
||
This starts a headless `delve` process for your IDE to connect to. The process listens on port `2346`, which is the port defined in our `launch.json` configuration. Somewhat related, the Mattermost server's `Makefile` has a command `debug-server-headless`, which starts a headless `delve` process for the Mattermost server, listening on port `2345`. So you can create a similar `launch.json` configuration in the server directory of the monorepo to connect to your server by using that port. |
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.
We should probably check in these launch.json files
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.
Are they just missing? What would be needed to add them?
|
||
In the script below, we automatically modify the file located at `${GOPATH}/pkg/mod/github.com/hashicorp/go-plugin@${GO_PLUGIN_PACKAGE_VERSION}/rpc_client.go`, where `GO_PLUGIN_PACKAGE_VERSION` is the version of `go-plugin` that your Mattermost server is using. This can be found in your local copy of the monorepo at [server/go.mod](https://github.com/mattermost/mattermost/blob/4bdd8bb18e47d16f9680905972516526b6fd61d8/server/go.mod#L141). | ||
|
||
This script essentially replaces the line in [go-plugin/rpc_client.go](https://github.com/hashicorp/go-plugin/blob/586d14f3dcef1eb42bfb7da4c7af102ec6638668/rpc_client.go#L66) to have a custom configuration for the RPC client connection, that disables the "keep alive" feature. This makes it so the debugger can be paused for long amounts of time, and the Mattermost server will keep the connection with the plugin open. |
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 section is wordy about describing the script. Also the section should probably contain instructions on how to do this manually, like the previous docs had
Newest code from mickmister has been published to preview environment for Git SHA e763268 |
Newest code from azigler has been published to preview environment for Git SHA 29bbb9b |
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.
Really fantastic update, @mickmister! 👍 💯 Thanks for taking the time to update this.
make attach-headless | ||
``` | ||
|
||
This starts a headless `delve` process for your IDE to connect to. The process listens on port `2346`, which is the port defined in our `launch.json` configuration. Somewhat related, the Mattermost server's `Makefile` has a command `debug-server-headless`, which starts a headless `delve` process for the Mattermost server, listening on port `2345`. So you can create a similar `launch.json` configuration in the server directory of the monorepo to connect to your server by using that port. |
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.
Are they just missing? What would be needed to add them?
Newest code from azigler has been published to preview environment for Git SHA 9221588 |
@azigler Yes they need to be added to the repos as |
Could we provide an example file inline in this docs PR? |
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.
Awesome 🚀
Newest code from mickmister has been published to preview environment for Git SHA 2c3a4e1 |
Newest code from mickmister has been published to preview environment for Git SHA 99dcd1b |
@azigler Yeah there's an example mattermost-developer-documentation/site/content/integrate/plugins/developer-workflow.md Lines 120 to 132 in 2c3a4e1
|
Newest code from cwarnermm has been published to preview environment for Git SHA 4fa21ac |
Newest code from hanzei has been published to preview environment for Git SHA 4fa21ac |
@cwarnermm We got two dev approvals; I think that is enough to hand the PR to you. |
Newest code from hanzei has been published to preview environment for Git SHA 4fa21ac |
Newest code from cwarnermm has been published to preview environment for Git SHA ad54f9e |
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.
Fantastic dev docs update!
Summary
Old docs
https://developers.mattermost.com/integrate/plugins/developer-workflow/#debug-server-side-plugins-using-delve
New docs
http://mattermost-dev-docs-preview-pulls.s3-website-us-east-1.amazonaws.com/1370/integrate/plugins/developer-workflow/#debug-server-side-plugins-using-delve
This PR updates the section on debugging server-side plugins on the Developer Workflow page. There are some changes due to previously having external libraries checked in a
vendor
folder, which now exist in Go modules.The PR includes a script to automate modifying the rpc_client.go file in the
go-plugin
package, to allow for long pauses from the debugger. Note there is an open PR upstream to implement this into the package hashicorp/go-plugin#101, as well as an issue I had opened for this a while ago hashicorp/go-plugin#248. Patching the library locally for development purposes seems harmless to me. I'm wondering if there's a more appropriate way to do this.Ticket Link
Fixes #1365