当前位置:网站首页>Supervisor series: 5. Log
Supervisor series: 5. Log
2022-07-28 04:56:00 【51CTO】
supervisor series :5、 journal
List of articles
supervisord One of the main tasks performed is logging .
supervisord An activity log will be recorded , Describe in detail what it does at runtime . It also sub processes stdout and stderr Output records to other files ( If configured to do so ).
1. Activity log
Activity log is supervisord Record your health 、 Sub process status changes 、 Any messages generated by the event, as well as debugging and information messages . The path of the activity log is through the configuration file [supervisord] In section logfile Parameter configuration , The default is $CWD/supervisord.log. If the value of this option is a special string syslog, Then the activity log will be routed to syslog service , Instead of writing to a file . An example of activity log traffic is shown below . In order to better adapt to the screen , Some lines are broken .
1.1 Example of activity log output
Activity log “level” In the configuration file [supervisord]ini In the document section loglevel Parameter configuration . Set up loglevel after , Messages with a specified priority and messages with a higher priority will be recorded in the activity log . for example , If loglevel by error, Will record error and critical Priority messages . however , If loglevel by warn, Will record warn、error and critical news .
1.2 Activity log level
The following table describes log levels in more detail , Sort from the highest priority to the lowest priority .“ Profile values ” Is in the configuration file [supervisord] Partially provided to loglevel String for parameter ,“ Output code ” Is the code displayed in the output line of the activity log .
Profile values | Output encoding | describe |
critical | CRIT | Indicates the conditions that require the user's immediate attention 、 Message of administrator status change or administrator's own error . |
error | ERRO | A message indicating a potentially negligible error condition ( for example , Unable to clear the log directory ). |
warn | WARN | Indicates an abnormal condition ( It's not a mistake ) The news of . |
info | INFO | Normal information output . If the log level is not explicitly configured , Then this is the default log level . |
debug | DEBG | For trying to debug process configuration and communication behavior ( Process output 、 Listener state changes 、 Event notification ) Useful messages for users . |
trace | TRAC | Useful messages for developers trying to debug management plug-ins , And about the HTTP and RPC Request and response information . |
blather | BLAT | Yes, try debugging supervisor Useful news for its own developers . |
1.3 Activity log rotation
According to the configuration file [supervisord] In section logfile_maxbytes and logfile_backups Combination of parameters ,supervisord The activity log will be rotated . When the activity log reaches logfile_maxbytes Byte time , The current log file will be moved to the backup file , And create a new activity log file . When this happens , If the number of existing backup files is greater than or equal to logfile_backups, Delete the oldest backup file , And rename the backup file accordingly . If the file name being written is supervisord.log, When it exceeds logfile_maxbytes when , It will be closed and renamed supervisord.log.1, If the file supervisord.log.1, supervisord.log.2 And so on already exist , Then rename it to supervisord.log.2, supervisord.log.3 etc. . If logfile_maxbytes by 0, Log files will never be converted ( So never back up ). If logfile_backups by 0, Do not keep any backups .
2. Child process log
By default , Will catch supervisor The standard output of the generated subprocess , So that it can be redisplayed to supervisorctl And other client users . If the [program:x],[fcgi-program:x], or [eventlistener:x] Some do not implement specific configurations related to log files , Then for true:
- supervisord The... Of the child process will be captured stdout and stderr Output to temporary file . Each stream is captured in a separate file . That's what's called
AUTO Logging mode . -
AUTO Log files are automatically named , And put it in the [supervisord] Part of the childlogdir Under the table of contents . - Every
AUTO The size of the log file is determined by the {streamname}_logfile_maxbytes Value limit ( among {streamname} yes " stdout “ or ” stderr "). When it reaches this number , It will be based on {streamname}_logfile_backups Rotation ( Just like the activity log ).
Affect child process login [program:x] and [fcgi-program:x] The configuration keywords of section are as follows :
redirect_stderr, stdout_logfile, stdout_logfile_maxbytes, stdout_logfile_backups, stdout_capture_maxbytes, stdout_syslog, stderr_logfile, stderr_logfile_maxbytes, stderr_logfile_backups, stderr_capture_maxbytes, and stderr_syslog.
[eventlistener:x] Segments may not specify redirect_stderr、stdout_capture_maxbytes or stderr_capture_maxbytes, But otherwise they accept the same value .
stay [supervisord] The configuration keywords that affect the logging of child processes in the configuration file section are :childlogdir and nocleanup.
2.1 Capture mode
The capture mode is Supervisor An advanced feature of . You don't need to understand capture patterns , Unless you want to take action based on the data parsed from the child process output .
If the [program:x] Section defines a nonzero stdout_capture_maxbytes or stderr_capture_maxbytes Parameters , from program Each process represented in part can be represented in its stdout or stderr flow ( , respectively, ) Send a special token on , This will effectively lead to supervisor issue PROCESS_COMMUNICATION event ( Description of the event , see also Events).
The process communication protocol relies on two tags , A command supervisor Enter capture mode , Another command exits . When the process flow enters capture mode , The data sent to the stream will be sent to a separate buffer in memory , Capture buffer , The buffer is allowed to contain the largest capture_maxbytes byte . In capture mode , When the length of the buffer exceeds capture_maxbytes Byte time , The oldest data in the buffer will be discarded , To make room for new data . When a process flow exits capture mode , One PROCESS_COMMUNICATION The event subtype will be supervisor Trigger , It may be intercepted by event listeners .
Start in the process flow “ Capture mode ” The sign of is <!--XSUPERVISOR:BEGIN-->. The flag to exit capture mode is <!--XSUPERVISOR:END-->. The data between these tags can be arbitrary , And constitute PROCESS_COMMUNICATION Payload of events . for example , If a program stdout_capture_maxbytes Set to “1MB”, It is in its stdout Send the following content on the stream :
under these circumstances ,supervisord Will send out a PROCESS_COMMUNICATIONS_STDOUT event , It contains the payload “Hello!” Data in .
One ( use Python Compiling ) An example script that emits process communication events is located at supervisor Bag scripts Directory , be known as sample_comment.py.
Designated as “ Event listener ”([eventlistener:x] section ) The output of the process will not be processed in this way . The output of these processes cannot enter capture mode .
边栏推荐
- When initializing with pyqt5, super() and_ init _ () problems faced by the coordinated use of functions, as well as the corresponding learning and solutions
- 全方位分析STEAM和创客教育的差异化
- [high CPU consumption] software_ reporter_ tool.exe
- [idea] check out master invalid path problem
- 【CPU占用高】software_reporter_tool.exe
- ADB environment configuration
- POJ 3728 the merchant (online query + double LCA)
- HDU 3592 World Exhibition (differential constraint)
- Printf() print char* str
- printf()打印char* str
猜你喜欢

Interview fraud: there are companies that make money from interviews
![[idea] check out master invalid path problem](/img/83/d36362ba314177cd6f1f74f3e922cd.png)
[idea] check out master invalid path problem

RT_ Use of thread mailbox

猿辅导技术进化论:助力教与学 构想未来学校

Is low code the future of development? On low code platform

王爽汇编语言详细学习笔记三:寄存器(内存访问)

动态sql和分页

Design and development of C language ATM system project

Dynamic SQL and paging

Redis类型
随机推荐
(manual) [sqli labs27, 27a] error echo, Boolean blind injection, filtered injection
HDU 3666 the matrix problemdifferential constraint + stack optimization SPFA negative ring
Chuangyuan will join hands with 50+ cloud native enterprises to explore new models to cross the digital divide
CPU and memory usage are too high. How to modify RTSP round robin detection parameters to reduce server consumption?
Analyze the emotional elements contained in intelligent sweeping robot
Can plastics comply with gb/t 2408 - Determination of flammability
Cmake usage base summary
外卖系统 文件上传
Odoo action analysis (action.client, action.act_window, action.server)
UI automation test farewell from now on, manual download browser driver, recommended collection
Interview fraud: there are companies that make money from interviews
Artificial intelligence and RPA technology application (I) -rpa Hongji product introduction, designer interface function explanation
Observable time series data downsampling practice in Prometheus
[函数文档] torch.histc 与 paddle.histogram 与 numpy.histogram
After a year of unemployment, I learned to do cross-border e-commerce and earned 520000. Only then did I know that going to work really delayed making money!
解析智能扫地机器人中蕴含的情感元素
set与list性能对比
[Sylar] framework Chapter 23 summary of module chapter
The difference between alter and confirm, prompt
阿里巴巴面试题【杭州多测师】【杭州多测师_王sir】