Linux Supervisord-将进程标准重定向到控制台
我计划使用supervisor运行多个进程,请在下面找到我的supervisord.conf文件:Linux Supervisord-将进程标准重定向到控制台,linux,supervisord,child-process,Linux,Supervisord,Child Process,我计划使用supervisor运行多个进程,请在下面找到我的supervisord.conf文件: [supervisord] [program:bash] command=xyz stdout_logfile =/tmp/bash.log redirect_stderr=true [supervisorctl] serverurl=unix:///tmp/supervisor.sock [unix_http_server] file=/tmp/supervisor.sock ; path
[supervisord]
[program:bash]
command=xyz
stdout_logfile =/tmp/bash.log
redirect_stderr=true
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
我希望将名为bash的进程的stdout重定向到supervisor控制台,以便在启动supervisor时使用
/usr/bin/supervisord
命令,我可以看到子进程日志。我该怎么做?我尝试将syslog设置为stdout_logfile属性,但没有成功。Update
请参阅下面的例会记录。监管者肯定抓住了平的机会。你还需要什么
(svd)08/09 16:26 [nodakai@kaidev01] ~/prog/svd$ cat supervisord.conf
[supervisord]
[program:ping]
command=ping 8.8.8.8
stdout_logfile =/tmp/ping.log
redirect_stderr=true
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
[unix_http_server]
file = /tmp/supervisor.sock
[inet_http_server]
port = 127.0.0.1:9001
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
(svd)08/09 16:26 [nodakai@kaidev01] ~/prog/svd$ supervisorctl -c supervisord.conf
ping RUNNING pid 27365, uptime 0:02:02
supervisor> tail ping
: icmp_req=97 ttl=48 time=59.1 ms
64 bytes from 8.8.8.8: icmp_req=98 ttl=48 time=59.2 ms
64 bytes from 8.8.8.8: icmp_req=99 ttl=48 time=59.1 ms
64 bytes from 8.8.8.8: icmp_req=100 ttl=48 time=59.4 ms
64 bytes from 8.8.8.8: icmp_req=101 ttl=48 time=59.8 ms
64 bytes from 8.8.8.8: icmp_req=102 ttl=48 time=59.2 ms
64 bytes from 8.8.8.8: icmp_req=103 ttl=48 time=59.4 ms
64 bytes from 8.8.8.8: icmp_req=104 ttl=48 time=59.5 ms
64 bytes from 8.8.8.8: icmp_req=105 ttl=48 time=59.6 ms
64 bytes from 8.8.8.8: icmp_req=106 ttl=48 time=59.5 ms
64 bytes from 8.8.8.8: icmp_req=107 ttl=48 time=60.1 ms
64 bytes from 8.8.8.8: icmp_req=108 ttl=48 time=59.4 ms
64 bytes from 8.8.8.8: icmp_req=109 ttl=48 time=59.5 ms
64 bytes from 8.8.8.8: icmp_req=110 ttl=48 time=59.5 ms
64 bytes from 8.8.8.8: icmp_req=111 ttl=48 time=59.4 ms
64 bytes from 8.8.8.8: icmp_req=112 ttl=48 time=59.1 ms
64 bytes from 8.8.8.8: icmp_req=113 ttl=48 time=59.3 ms
64 bytes from 8.8.8.8: icmp_req=114 ttl=48 time=59.2 ms
64 bytes from 8.8.8.8: icmp_req=115 ttl=48 time=59.4 ms
64 bytes from 8.8.8.8: icmp_req=116 ttl=48 time=59.5 ms
64 bytes from 8.8.8.8: icmp_req=117 ttl=48 time=59.5 ms
64 bytes from 8.8.8.8: icmp_req=118 ttl=48 time=59.6 ms
64 bytes from 8.8.8.8: icmp_req=119 ttl=48 time=59.4 ms
64 bytes from 8.8.8.8: icmp_req=120 ttl=48 time=59.4 ms
64 bytes from 8.8.8.8: icmp_req=121 ttl=48 time=59.2 ms
64 bytes from 8.8.8.8: icmp_req=122 ttl=48 time=59.3 ms
64 bytes from 8.8.8.8: icmp_req=123 ttl=48 time=59.5 ms
64 bytes from 8.8.8.8: icmp_req=124 ttl=48 time=59.5 ms
64 bytes from 8.8.8.8: icmp_req=125 ttl=48 time=59.3 ms
supervisor>
原职
读到你的回复,我实际上有点困惑,因为这是supervisord
守护进程的基本功能。也许您对所谓的“supervisord console”有一些误解??用于启动supervisord
守护进程的bash控制台不会打印任何内容。您需要通过使用serverurl=unix:///tmp/supervisor.sock
和文件=/tmp/supervisor.sock
行
(svd)08/09 3:51 [nodakai@kaidev01] ~/prog/svd$ supervisorctl -c supervisord.conf
foo FATAL Exited too quickly (process log may have details)
supervisor> help
default commands (type help <topic>):
=====================================
add clear fg open quit remove restart start stop update
avail exit maintail pid reload reread shutdown status tail version
supervisor> tail foo
-rw-r-- 1 nodakai nodakai 1521 8月 9 03:43 supervisord.log
-rw-r--r-- 1 nodakai nodakai 6 8月 9 03:43 supervisord.pid
合計 32
drwxrwxr-x 2 nodakai nodakai 4096 8月 9 03:10 bin
drwxrwxr-x 2 nodakai nodakai 4096 8月 9 03:07 include
drwxrwxr-x 3 nodakai nodakai 4096 8月 9 03:07 lib
drwxrwxr-x 2 nodakai nodakai 4096 8月 9 03:07 local
-rw-rw-r-- 1 nodakai nodakai 346 8月 9 03:43 supervisord.conf
-rw-rw-r-- 1 nodakai nodakai 340 8月 9 03:42 supervisord.conf~
-rw-rw-r-- 1 nodakai nodakai 1651 8月 9 03:43 supervisord.log
-rw-r--r-- 1 nodakai nodakai 6 8月 9 03:43 supervisord.pid
合計 32
drwxrwxr-x 2 nodakai nodakai 4096 8月 9 03:10 bin
drwxrwxr-x 2 nodakai nodakai 4096 8月 9 03:07 include
drwxrwxr-x 3 nodakai nodakai 4096 8月 9 03:07 lib
drwxrwxr-x 2 nodakai nodakai 4096 8月 9 03:07 local
-rw-rw-r-- 1 nodakai nodakai 346 8月 9 03:43 supervisord.conf
-rw-rw-r-- 1 nodakai nodakai 340 8月 9 03:42 supervisord.conf~
-rw-rw-r-- 1 nodakai nodakai 1781 8月 9 03:43 supervisord.log
-rw-r--r-- 1 nodakai nodakai 6 8月 9 03:43 supervisord.pid
合計 32
drwxrwxr-x 2 nodakai nodakai 4096 8月 9 03:10 bin
drwxrwxr-x 2 nodakai nodakai 4096 8月 9 03:07 include
drwxrwxr-x 3 nodakai nodakai 4096 8月 9 03:07 lib
drwxrwxr-x 2 nodakai nodakai 4096 8月 9 03:07 local
-rw-rw-r-- 1 nodakai nodakai 346 8月 9 03:43 supervisord.conf
-rw-rw-r-- 1 nodakai nodakai 340 8月 9 03:42 supervisord.conf~
-rw-rw-r-- 1 nodakai nodakai 1911 8月 9 03:43 supervisord.log
-rw-r--r-- 1 nodakai nodakai 6 8月 9 03:43 supervisord.pid
supervisor> status
foo FATAL Exited too quickly (process log may have details)
supervisor> quit
(svd)08/09 3:51 [nodakai@kaidev01] ~/prog/svd$
有关详细信息,请参阅。您可以使用以下配置选项将程序的标准输出重定向到主管的标准输出:
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
说明:
- 当进程打开
(与/dev/fd/1
相同)时,系统实际上会克隆该进程的文件描述符1(stdout)。将其用作/proc/self/fd/1
会导致stdout\u日志文件
将程序的stdout重定向到自己的stdoutsupervisord
禁用日志文件旋转,这显然对stdout没有意义。不指定此选项将导致错误,因为默认值为50MB,并且supervisor不够聪明,无法检测到指定的日志文件不是常规文件stdout\u logfile\u maxbytes=0
您能澄清一下您的问题吗?这可能是因为您没有在
命令=
行中指定bash
?xyz可以是任何命令。我面临的问题是,我试图在supervisord控制台中查看子进程日志。例如,如果该命令是一个列表命令,我希望在supervisord控制台中看到它的输出。感谢您的回复。我知道您可以使用supervisorctl查看子进程的状态、日志等。但由于某些限制,我希望启动supervisord进程(使用/usr/bin/supervisord),并希望以显示子进程输出的方式对其进行配置。明白我的意思了吗?我发现分享/proc/self/fd/1
实际上是指向/dev/stdout
的符号链接很有趣,当进程打开该文件时,系统实际上克隆了该进程的文件描述符1(stdout)。实际上,/dev/stdout
是指向/proc/self/fd/1
的符号链接,/dev/fd/1
是指向进程通信的任何对象的符号链接,但其结果大致相同。
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0