-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: add EmmyLuaDebugger hook #12899
Conversation
1604ee8
to
df3924c
Compare
21a587b
to
78e96a6
Compare
ba65830
to
59a1e01
Compare
fb32b72
to
555551d
Compare
555551d
to
19666a6
Compare
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.
Very nice addition, @hanshuebner! Wondering if this shouldn't be loaded along with luacov -- see https://github.com/kong/kong/blob/38ddd0e203240cdb1d6c5352ea4b5dca9de0ce51/kong/templates/nginx_kong.lua#L43. Maybe introducing a "dev" mode would be appropriate?
@gszr writes:
I'm not quite sure - luacov seems to be useful when running (all) tests, while the debugger really only helps in interactive mode. Also, if I understand you well, you're suggesting that a "dev" mode should exist which enables certain things. We'd have to ship EmmyLuaDebugger in that case, otherwise one would have to enable "dev" mode and specify the location of the debugger shared library. If it'd be the other way round and setting I think debuggers are most useful if they require little or no setup. I think with the current setup, it is possible to always set the |
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.
Just checking.
502ebb7
to
8f17e34
Compare
030167d
to
1c5661c
Compare
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.
successfully tested on Ubuntu 22.04.
Ubuntu 20.04's GLIBC version is too low however. We may want to include glibc version requirements in the docs at some point.
2e7d837
to
c67a6a9
Compare
The change provides a hook in the init_worker phase to start the EmmyLua debugger. The debugger is enabled by setting the `KONG_EMMY_DEBUGGER` to the absolute pathname of the EmmyLuaDebugger shared library (e.g. /usr/local/bin/emmy_core.dylib). The host and port that the debugger interface listens on can be defined by setting the `KONG_EMMY_DEBUGGER_HOST` and `KONG_EMMY_DEBUGGER_PORT` environment variables, respectively. If the environment variable `KONG_EMMY_DEBUGGER_WAIT` is set, the debugger hook waits for the IDE to connect at the beginning of the worker startup process to allow debugging of startup issues. Kong should be started with KONG_NGINX_WORKER_PROCESSES set to 1 to enable only one worker process. Debugging multiple worker processes is not supported. This feature is based on work by @mehuled, published in https://dev.to/mehuled/breakpoint-debugging-with-kong-plugin-development-75a
c67a6a9
to
23f751f
Compare
I've added a paragraph to DEVELOPER.md. |
Comment resolved - cpath is now only changed while loading debugger
Successfully created cherry-pick PR for |
Summary
The change provides a hook in the init_worker phase to start the EmmyLua debugger. The debugger is enabled by setting the
KONG_EMMY_DEBUGGER
to the absolute pathname of the EmmyLuaDebugger shared library (e.g. /usr/local/bin/emmy_core.dylib). The host and port that the debugger interface listens on can be defined by setting theKONG_EMMY_DEBUGGER_HOST
andKONG_EMMY_DEBUGGER_PORT
environment variables, respectively.If the environment variable
KONG_EMMY_DEBUGGER_WAIT
is set, the debugger hook waits for the IDE to connect at the beginning of the worker startup process to allow debugging of startup issues.Kong should be started with
KONG_NGINX_WORKER_PROCESSES
set to 1 to enable only one worker process. Debugging multiple worker processes is not supported.This feature is based on work by @mehuled, published in
https://dev.to/mehuled/breakpoint-debugging-with-kong-plugin-development-75a
Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdKAG-4316