代码之家  ›  专栏  ›  技术社区  ›  TechSavy

无法用django启动主管

  •  1
  • TechSavy  · 技术社区  · 6 年前

    我有一个django应用程序,我使用芹菜来运行后台任务。 我正在利用主管管理芹菜,但当我运行: sudo supervisorctl reread ,它给出了以下错误:

    Traceback (most recent call last):
    File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 578, in _build_master
    ws.require(__requires__)
    File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 895, in require
    needed = self.resolve(parse_requirements(requirements))
    File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
     pkg_resources.VersionConflict: (supervisor 4.0.0.dev0 (/home/user/.local/lib/python3.6/site-packages), 
      Requirement.parse('supervisor==3.3.1'))
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "/usr/bin/supervisorctl", line 6, in <module>
    from pkg_resources import load_entry_point
    File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3112, in <module>
    @_call_aside
    File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3096, in _call_aside
    f(*args, **kwargs)
    File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3125, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
    File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 580, in _build_master
    return cls._build_from_requirements(__requires__)
     File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 593, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
      File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 781, in resolve
    raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'supervisor==3.3.1' distribution was not found and is required by the application
    

    使用supervisiord配置文件更新:

    supervisord.conf文件:

    ; 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)
    
    ; 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 = /etc/supervisor/conf.d/*.conf
    

    芹菜配置文件:

    芹菜proj_worker.conf

    ; ==================================
    ; celery worker supervisor example
    ; ==================================
    ; the name of your supervisord program
     [program:proj_worker]
    ; Set full path to celery program if using virtualenv
     command=/home/me/proj/venv/bin/celery -A proj worker -l info
     ; The directory to your Django project
    directory=/home/me/proj
    ; If supervisord is run as the root user, switch users to this UNIX 
     user account before doing any processing.
    user=me
    ; Supervisor will start as many instances of this program as named by 
    numprocs
    numprocs=1
    ; Put process stdout output in this file 
    stdout_logfile=/var/log/celery/proj_worker.log
    ; Put process stderr output in this file 
     stderr_logfile=/var/log/celery/proj_worker.log
     ; If true, this program will start automatically when supervisord is 
     started
      autostart=true
     ; May be one of false, unexpected, or true. If false, the process will never be autorestarted. If unexpected, the process will be restart when the program exits with an exit code that is not one of the exit codes associated with this process’ configuration (see exitcodes). If true, the process will be unconditionally restarted when it exits, without regard to its exit code.
      autorestart=true
      ; The total number of seconds which the program needs to stay running after a startup to consider the start successful.
     startsecs=10
     ; Need to wait for currently executing tasks to finish at shutdown. ; Increase this if you have very long running tasks.
     stopwaitsecs = 600 
     ; When resorting to send SIGKILL to the program to terminate it ; send SIGKILL to its whole process group instead, taking care of its children as well.
     killasgroup=true
     ; if your broker is supervised, set its priority higher so it starts first
    priority=998
    

    芹菜proj_beat.conf

    ; ================================
    ;  celery beat supervisor example
    ; ================================ 
    ; the name of your supervisord program
    [program:projbeat]
    ; Set full path to celery program if using virtualenv
     command=/home/me/proj/venv/bin/celery -A proj beat -l info
    ; The directory to your Django project
    directory=/home/me/proj
    ; If supervisord is run as the root user, switch users to this UNIX 
    user account before doing any processing.
    user=me
    ; Supervisor will start as many instances of this program as named by numprocs
    numprocs=1
    ; Put process stdout output in this file 
     stdout_logfile=/var/log/celery/proj_beat.log
    ; Put process stderr output in this file 
     stderr_logfile=/var/log/celery/proj_beat.log
    ; If true, this program will start automatically when supervisord is started
    autostart=true
     ; May be one of false, unexpected, or true. If false, the process will never be autorestarted. If unexpected, the process will be restart when the program exits with an exit code that is not one of the exit codes associated with this process’ configuration (see exitcodes). If true, the process will be unconditionally restarted when it exits, without regard to its exit code.
    autorestart=true
    ; The total number of seconds which the program needs to stay running after a startup to consider the start successful.
    startsecs=10
    ; if your broker is supervised, set its priority higher so it starts first
    priority=999
    

    欢迎提出任何建议。 提前谢谢。

    1 回复  |  直到 5 年前
        1
  •  0
  •   Yvette    6 年前

    基于主管 documents ,它在任何版本的python 3下都无法工作。

    推荐文章