简体   繁体   English

Mendix:在 docker 容器中启用调试器

[英]Mendix: enabling debugger in docker container

we use Mendix for some of our custom-apps;我们将 Mendix 用于我们的一些定制应用程序; we are getting ready to migrate from m2ee-tools to docker deplyments of on-premise systems.我们正准备从m2ee-tools迁移到本地系统的 docker 部署。 This is because Mendix drops support for m2ee-tools beginning with Centos/RHEL 8, and the latest supported Centos/RHEL 7 end of life is in about 2 years (June 2024).这是因为 Mendix 从 Centos/RHEL 8 开始放弃对m2ee-tools的支持,而最新支持的 Centos/RHEL 7 的生命周期结束时间约为 2 年(2024 年 6 月)。

We got stuck on one key point in our proof-of-concept scenario and need help:我们在概念验证场景中遇到了一个关键点,需要帮助:

How to enable/disable debugger in a Mendix app that is running in a docker container?如何在 docker 容器中运行的 Mendix 应用程序中启用/禁用调试器?

What we have already found:我们已经发现:

  1. -e DEBUGGER_PASSWORD=”stringData” -e DEBUGGER_PASSWORD=”stringData”

We are aware of triggering the debugger at container's startup by providing them with a variable DEBUGGER_PASSWORD="stringData", but then the debugger is enabled throughout the lifetime of this instance of container which is undesired.我们知道在容器启动时通过为它们提供变量 DEBUGGER_PASSWORD="stringData" 来触发调试器,但随后在此容器实例的整个生命周期中都启用了调试器,这是不希望的。

  1. Partial knowledge: POST request is used to communicate with a debugger部分知识:POST请求用于与调试器通信

From some in-depth analysys we have also found that the debugger is normally enabled on a running Mendix application by a POST request to a running app.从一些深入的分析中,我们还发现调试器通常通过对正在运行的应用程序的 POST 请求在正在运行的 Mendix 应用程序上启用。 However, we are currently unaware of what the message body is.但是,我们目前不知道消息正文是什么。

We have identified the answer.我们已经确定了答案。 Since finding the answer was not trivial, the original question has been unanswered for 3 weeks, and has received an upvote, therefore I will add the answer to this thread so it is usefull in case other Mendix developers search for "docker" + "debugger".由于找到答案并非易事,原来的问题已经 3 周没有答案了,并且已经收到了赞成票,因此我会将答案添加到这个帖子中,这样在其他 Mendix 开发人员搜索“docker”+“debugger”时很有用”。

The solution delivered in bash bash中交付的解决方案

A container parametrized and started using the following command:使用以下命令参数化并启动的容器:

docker run -it -p 8088:8080  \
    -e ADMIN_PASSWORD='ApplicationAdminPassword1'  \
    -e DATABASE_ENDPOINT='postgres://pgPassword:pgUser@192.168.0.1:5432/pgDbName'  \
    -e M2EE_PASSWORD='PasswordForAdministrativeTasks1'  \
    mendix/mendix-buildpack:v1.2

can have the debugger enabled like this:可以像这样启用调试器:

curl -X POST -u 'MxAdmin:PasswordForAdministrativeTasks1'  \
     -H "Content-Type: application/json"  \
     -H "X-M2EE-Authentication: `echo -n 'PasswordForAdministrativeTasks1' | base64`"  \
     -H "Connection: close"  \
     -d '{"action": "enable_debugger", "params": {"password": "aRandomPassForDebugger1"}}' \
     localhost:8088/_mxadmin/; echo

and the debugger is available as normal, via the address http://applicationHostIP:8088/debugger/ using the pasword you have declared "aRandomPassForDebugger1".并且调试器可以正常使用,通过地址http://applicationHostIP:8088/debugger/使用您声明的密码“aRandomPassForDebugger1”。 M2ee-tools seem to be using alphanumeric characters only (perhaps in order to avoid troubles with special caracters in certain contexts or situations) - in this case the password strength has to be obtained by lengthening it. M2ee-tools 似乎只使用字母数字字符(也许是为了避免在某些上下文或情况下出现特殊字符的麻烦) - 在这种情况下,必须通过延长密码强度来获得密码强度。 M2ee-tools use more than 20 characters. M2ee-tools 使用超过 20 个字符。

The second action can in fact be performed using a variety of tools, not ecesairly with curl.第二个动作实际上可以使用多种工具执行,而不是使用 curl。

Comments on the solution对解决方案的评论

Two manuals were helpful, but required some effort to "comsume" and be turned into a method for enabling the debugger.两本手册很有帮助,但需要付出一些努力才能“接受”并转化为启用调试器的方法。 The manuals can be found at docs.mendix.com and at github.com/mendix .这些手册可以在docs.mendix.comgithub.com/mendix上找到。

As you can see, in order to communicate with the runtime, you need to send a POST message with simple auth and the additional headers.如您所见,为了与运行时通信,您需要发送带有简单身份验证和附加标头的 POST 消息。 Mendix team has decided to migrate from an admin-port used by m2ee-tools to a service available in the docker container at "_mxadmin" directory of the application-provisioning web-end. Mendix 团队决定从 m2ee-tools 使用的管理端口迁移到应用程序供应 Web 端的“_mxadmin”目录中 docker 容器中可用的服务。

Pay attention to this part:注意这部分:

-H "X-M2EE-Authentication: `echo -n 'PasswordForAdministrativeTasks1' | base64`"

It is a header with base64-encoded password (yes, the same password provided again in the same POST message, just provided in a different form).它是一个 header,带有 base64 编码的密码(是的,在同一个 POST 消息中再次提供了相同的密码,只是以不同的形式提供)。 You can substitute the inline (that calculates base64) with the off-line-made string, which in this example is UGFzc3dvcmRGb3JBZG1pbmlzdHJhdGl2ZVRhc2tzMQ== .您可以用离线制作的字符串替换内联(计算base64),在本例中为UGFzc3dvcmRGb3JBZG1pbmlzdHJhdGl2ZVRhc2tzMQ==

Note that the message's paylod is a json data structure.请注意,消息的有效载荷是 json 数据结构。 Many payload-actions require only the "action" clause, but some other additionaly require parameters (like enable_debugger).许多有效负载操作只需要“action”子句,但其他一些额外需要参数(如 enable_debugger)。

Actions related to the topic与主题相关的操作

  • enable_debugger '{"action": "enable_debugger", "params": {"password": "aStrongPass"}}' enable_debugger '{"action": "enable_debugger", "params": {"password": "aStrongPass"}}'
  • get_debugger_status '{"action": "get_debugger_status"}' get_debugger_status '{"action": "get_debugger_status"}'
  • disable_debugger '{"action": "disable_debugger"}' disable_debugger '{"action": "disable_debugger"}'
  • get_admin_action_info '{"action": "get_admin_action_info"}' get_admin_action_info '{"action": "get_admin_action_info"}'

The last listed action (get_admin_action_info) has a potential to be particularily useful for figuring out many other actions for communicating with the runtime-messaging (it returns a list of available actions), so try it out yourself.最后列出的操作 (get_admin_action_info) 可能对找出与运行时消息通信的许多其他操作特别有用(它返回可用操作的列表),所以自己尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CLion调试器在Docker容器中失败 - CLion Debugger Fails in Docker Container 使用 Docker for Mendix 有什么不同? - What is the difference that we are making by using Docker for Mendix? Docker 容器在启用 systemd 脚本的情况下重新启动后无法启动 - Docker container doesn't start after reboot with enabling systemd script 使用 Xdebug 作为调试器在 Docker 容器上使用 VSCode 调试 Laravel - Debugging Laravel with VSCode on Docker container using Xdebug as debugger 在Windows容器中运行Visual Studio远程调试器(Docker托管) - Running Visual Studio Remote Debugger in Windows Container (Docker managed) 以编程方式将调试器附加到在 Docker 容器内运行的进程 - Programmatically attach a debugger to a process running inside a Docker Container PHP / 如何在远程 Docker 容器上使用远程调试器 - PHP / How to use remote debugger on remote Docker container 如何使用 VisualStudio docker 调试器(launchSettings.json 配置文件)从 Docker 容器公开自定义端口 (TCP)? - How to expose custom port (TCP) from Docker container using VisualStudio docker debugger (launchSettings.json profile)? 如何在 docker 容器中使用带有 odoo 的 VS 代码调试器 [vs code + odoo + docker + mac] - How to use VS code debugger with odoo in a docker container [vs code + odoo + docker + mac] 为Kibana启用docker模块 - Enabling docker module for Kibana
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM