lsswear 2024-09-04 14:06 采纳率: 25%
浏览 3

Supervisor 子线程启动失败?

报错

Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.

本地安装:apt-get install python3-pip

/etc/supervisord.conf

; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
;    variables can be expanded using this syntax: "%(ENV_HOME)s".
;  - Quotes around values are not supported, except in the case of
;    the environment= options as shown below.
;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
;  - Command will be truncated if it looks like a config file comment, e.g.
;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
;
; Warning:
;  Paths throughout this example file use /tmp because it is available on most
;  systems.  You will likely need to change these to locations more appropriate
;  for your system.  Some systems periodically delete older files in /tmp.
;  Notably, if the socket file defined in the [unix_http_server] section below
;  is deleted, supervisorctl will be unable to connect to supervisord.
 
[unix_http_server]
file=/tmp/supervisor.sock   ; the path to the socket file
;chmod=0700                 ; socket file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)
 
; Security Warning:
;  The inet HTTP server is not enabled by default.  The inet HTTP server is
;  enabled by uncommenting the [inet_http_server] section below.  The inet
;  HTTP server is intended for use within a trusted environment only.  It
;  should only be bound to localhost or only accessible from within an
;  isolated, trusted network.  The inet HTTP server does not support any
;  form of encryption.  The inet HTTP server does not use authentication
;  by default (see the username= and password= options to add authentication).
;  Never expose the inet HTTP server to the public internet.
 
;[inet_http_server]         ; inet (TCP) server disabled by default
;port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)
 
[supervisord]
logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
loglevel=info                ; log level; default info; others: debug,warn,trace
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false               ; start in foreground if true; default false
silent=false                 ; no logs to stdout if true; default false
minfds=1024                  ; min. avail startup file descriptors; default 1024
minprocs=200                 ; min. avail process descriptors;default 200
;umask=022                   ; process file creation umask; default 022
;user=supervisord            ; setuid to this UNIX account at startup; recommended if root
;identifier=supervisor       ; supervisord identifier, default is 'supervisor'
;directory=/tmp              ; default is not to cd during start
;nocleanup=true              ; don't clean up tempfiles at start; default false
;childlogdir=/tmp            ; 'AUTO' child log dir, default $TEMP
;environment=KEY="value"     ; key value pairs to add to environment
;strip_ansi=false            ; strip ansi escape codes in logs; def. false
 
; The rpcinterface:supervisor 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:x] sections.
 
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
 
; The supervisorctl section configures how supervisorctl will connect to
; supervisord.  configure it match the settings in either the unix_http_server
; or inet_http_server section.
 
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=root
;username=chris              ; should be same as in [*_http_server] if set
;password=123                ; should be same as in [*_http_server] if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history  ; use readline history if available
 
; The sample program section below shows all possible program subsection values.
; Create one or more 'real' program: sections to be able to control them under
; supervisor.
 
;[program:theprogramname]
;command=/bin/cat              ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=999                  ; the relative start priority (default 999)
;autostart=true                ; start at supervisord start (default: true)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)
;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stdout_syslog=false           ; send stdout to syslog with process name (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;stderr_syslog=false           ; send stderr to syslog with process name (default false)
;environment=A="1",B="2"       ; process environment additions (def no adds)
;serverurl=AUTO                ; override serverurl computation (childutils)
 
; The sample eventlistener section below shows all possible eventlistener
; subsection values.  Create one or more 'real' eventlistener: sections to be
; able to handle event notifications sent by supervisord.
 
;[eventlistener:theeventlistenername]
;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;events=EVENT                  ; event notif. types to subscribe to (req'd)
;buffer_size=10                ; event buffer queue size (default 10)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=-1                   ; the relative start priority (default -1)
;autostart=true                ; start at supervisord start (default: true)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; autorestart if exited after running (def: unexpected)
;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=false         ; redirect_stderr=true is not allowed for eventlisteners
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stdout_syslog=false           ; send stdout to syslog with process name (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;stderr_syslog=false           ; send stderr to syslog with process name (default false)
;environment=A="1",B="2"       ; process environment additions
;serverurl=AUTO                ; override serverurl computation (childutils)
 
; The sample group section below shows all possible group values.  Create one
; or more 'real' group: sections to create "heterogeneous" process groups.
 
;[group:thegroupname]
;programs=progname1,progname2  ; each refers to 'x' in [program:x] definitions
;priority=999                  ; the relative start priority (default 999)
 
; 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 = /etc/supervisord.d/*.ini
 

/etc/supervisord.d/test.ini

;[program:theprogramname]
;;command=/bin/cat              ; the program (relative uses PATH, can take args)
;;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;;numprocs=1                    ; number of processes copies to start (def 1)
;;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;;umask=022                     ; umask for process (default None)
;;priority=999                  ; the relative start priority (default 999)
;;autostart=true                ; start at supervisord start (default: true)
;;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;;startretries=3                ; max # of serial start failures when starting (default 3)
;;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)
;;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
;;stopsignal=QUIT               ; signal used to kill process (default TERM)
;;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;;user=chrism                   ; setuid to this UNIX account to run the program
;;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
;;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;;stdout_syslog=false           ; send stdout to syslog with process name (default false)
;;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;;stderr_syslog=false           ; send stderr to syslog with process name (default false)
;;environment=A="1",B="2"       ; process environment additions (def no adds)
;;serverurl=AUTO
 
[program:test]
command=php /wj/test.php
directory=/wj
autostart=true
autorestart=true
startsecs=1
user=root
redirect_stderr=true
stdout_logfile=/root/test/test.log

启动:supervisord -c /etc/supervisord.conf

查看状态:supervisorctl -c /etc/supervisord.conf status

运行查看状态的命令后,无数据输出。

按网上查的加user=root。

查看日志:cat /tmp/supervisord.log

2024-09-03 07:32:47,999 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2024-09-03 07:32:48,003 INFO RPC interface 'supervisor' initialized
2024-09-03 07:32:48,003 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2024-09-03 07:32:48,005 INFO daemonizing the supervisord process
2024-09-03 07:32:48,005 INFO supervisord started with pid 11488

使用启动命令后还是报相同错误。

求指教……

  • 写回答

1条回答 默认 最新

  • 吃不了席 2024-09-04 17:41
    关注

    以下回复参考:皆我百晓生券券喵儿等免费微信小程序作答:

    要解决这个问题,首先确认在/etc/supervisord.conf文件中用户配置是否正确。根据您提供的信息,没有明确指定用户。建议修改configfile中的usernameuser,以确保程序能够作为普通用户启动并运行。

    然后,尝试重新执行启动命令,看看是否有任何差异。如果仍然遇到问题,可以考虑以下步骤进一步排查:

    1. 检查/etc/supervisord.conf文件内容:

      grep -E '^username=' /etc/supervisord.conf
      
    2. 如果username设置正确但仍然出现问题,可能是因为supervisorctl配置不正确。检查supervisorctl配置,确保它与supervisord配置匹配,并且监听端口(例如unix:///tmp/supervisor.sock)是正确的。

    3. 确保所有依赖包已更新至最新版本,如Python库、supervisord等。

    4. 使用sudo运行命令,这样可以确保只有系统管理员有权运行程序。

    5. 尝试将日志文件路径改为/var/log/supervisor.log或其他适当的路径,或者更改其他可能影响日志位置的配置选项。

    6. 如果问题依然存在,可能是由于某些环境变量未被正确设置。检查envsubst替换字符串中的环境变量值,并确保它们正确应用到您的环境中。

    希望以上建议能帮助解决问题!如果您还有其他疑问,请随时提问。

    评论

报告相同问题?

问题事件

  • 创建了问题 9月4日

悬赏问题

  • ¥15 求caverdock使用教程
  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。
  • ¥30 求给定范围的全体素数p的(p-2)/p的连乘积值