0

我有多个使用 supervisord 在 Ubuntu 后台运行的 .NET Core 程序(见下文)。该 supervisord.conf 位于 Hello-World 文件夹中。

[program:hello-world-1]
command = /all-hello-worlds/dotMemory-Cli-Linux/tools/dotMemory.sh start-net-core --service-input=null --trigger-max-snapshots=5 --trigger-delay=2m --trigger-timer=00:01:00 Hello-World-1.dll
directory = /all-hello-worlds/Hello-World-1
autostart = true
autorestart = unexpected
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0

在每个 supervisord.conf 中,我使用: dotMemory.sh start-net-core --trigger-delay=1m --trigger-timer=00:00:10 ./HelloWorld.dll

当 supervisord 在后台运行 .NET Core 程序时,我可以看到 dotMemory 打印消息说“Press Ctrl+C to end the profiling”

这些 .NET Core 程序捆绑在一个 Dorker 容器中,该容器运行/usr/bin/supervisord -c /all-hello-worlds/supervisord.conf

这是另一个名为 supervisord.confsupervisord.conf的文件,位于all-hello-worlds文件夹中

; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)
nodaemon = true   ; run in the background aka daemonizing

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.
[include]
files = /all-hello-worlds/*/supervisord.conf

您可以在 Ubuntu 中可视化文件夹结构,如下所示:

all-hello-worlds (root folder)
| --- dotMemory-Cli-Linux
| --- supervisord.conf
| --- Hello-World-1
   | --- Hello-World-1.dll
   | --- supervisord.conf
| --- Hello-World-2
   | --- Hello-World-2.dll
   | --- supervisord.conf

现在我很难将 Ctrl-C 命令发送到 supervisord Hello-World 进程。如果我使用supervisorctl stop Hello-World-1dotMemory 无法正确保存 DMW 文件,我需要使用dotMemory recover方法获取 DMW 文件(这很麻烦)

如果我使用kill -SIGINT [dotMemory process ID],supervisord 会重新启动进程并且不会正确保存 DMW 文件。

无论如何,是否可以将 Ctrl-C 命令发送到使用 supervisord 在后台运行的 dotMemory?我在这里附加了 2 个 supervisord.conf 文件。

如果您需要我提供更多信息,请告诉我。谢谢。

4

1 回答 1

1

您使用通过单声道运行的旧 dotMemory 控制台版本。kill -SIGINT [dotMemory process ID]命令不能正常工作。

但是,##dotMemory["disconnect"]可以通过文件发送到标准输入:

  • 使用参数修改命令行--service-input

dotMemory.sh start-net-core --service-input=<Path to service messages file>/dotMemoryInput.txt

  • 当您想停止分析会话时,编辑文件:

echo '##dotMemory["disconnect"]' >> <Path to service messages file>/dotMemoryInput.txt

在这种情况下,分析会话将完成并保存工作区。

另一种方法是将dotMemory clt版本更新为2021.1.5。由于 2021.1 dotMemory 通过 dotnet 运行,并且kill -SIGINT [dotMemory process ID]在该版本下正常工作,因此工作空间保存成功。

于 2021-07-28T12:07:31.010 回答