• supervisord管理Django项目


    最近在用Django3写运维管理平台,部分完成后上线使用,怕有性能问题,因此采用supervisord来管理启动

    supervisord配置如下

      1 [unix_http_server]
      2 file=/var/run/supervisor/supervisor.sock   ; (the path to the socket file)
      3 ;chmod=0700                 ; sockef file mode (default 0700)
      4 ;chown=nobody:nogroup       ; socket file uid:gid owner
      5 ;username=user              ; (default is no username (open server))
      6 ;password=123               ; (default is no password (open server))
      7 
      8 [inet_http_server]         ; inet (TCP) server disabled by default
      9 port=127.0.0.1:9001        ; (ip_address:port specifier, *:port for all iface)
     10 username=imcyunw              ; (default is no username (open server))
     11 password=匿了               ; (default is no password (open server))
     12 
     13 [supervisord]
     14 logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)
     15 logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
     16 logfile_backups=10          ; (num of main logfile rotation backups;default 10)
     17 loglevel=info               ; (log level;default info; others: debug,warn,trace)
     18 pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
     19 nodaemon=false              ; (start in foreground if true;default false)
     20 minfds=1024                 ; (min. avail startup file descriptors;default 1024)
     21 minprocs=200                ; (min. avail process descriptors;default 200)
     22 ;umask=022                  ; (process file creation umask;default 022)
     23 ;user=chrism                 ; (default is current user, required if root)
     24 ;identifier=supervisor       ; (supervisord identifier, default is 'supervisor')
     25 ;directory=/tmp              ; (default is not to cd during start)
     26 ;nocleanup=true              ; (don't clean up tempfiles at start;default false)
     27 ;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
     28 ;environment=KEY=value       ; (key value pairs to add to environment)
     29 ;strip_ansi=false            ; (strip ansi escape codes in logs; def. false)
     30 
     31 ; the below section must remain in the config file for RPC
     32 ; (supervisorctl/web interface) to work, additional interfaces may be
     33 ; added by defining them in separate rpcinterface: sections
     34 [rpcinterface:supervisor]
     35 supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
     36 
     37 [supervisorctl]
     38 serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket
     39 serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
     40 username=imcyunw              ; should be same as http_username if set
     41 password=imcdev2019#                ; should be same as http_password if set
     42 ;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
     43 ;history_file=~/.sc_history  ; use readline history if available
     44 
     45 ; The below sample program section shows all possible program subsection values,
     46 ; create one or more 'real' program: sections to be able to control them under
     47 ; supervisor.
     48 
     49 ;[program:theprogramname]
     50 ;command=/bin/cat              ; the program (relative uses PATH, can take args)
     51 ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
     52 ;numprocs=1                    ; number of processes copies to start (def 1)
     53 ;directory=/tmp                ; directory to cwd to before exec (def no cwd)
     54 ;umask=022                     ; umask for process (default None)
     55 ;priority=999                  ; the relative start priority (default 999)
     56 ;autostart=true                ; start at supervisord start (default: true)
     57 ;autorestart=true              ; retstart at unexpected quit (default: true)
     58 ;startsecs=10                  ; number of secs prog must stay running (def. 1)
     59 ;startretries=3                ; max # of serial start failures (default 3)
     60 ;exitcodes=0,2                 ; 'expected' exit codes for process (default 0,2)
     61 ;stopsignal=QUIT               ; signal used to kill process (default TERM)
     62 ;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
     63 ;user=chrism                   ; setuid to this UNIX account to run the program
     64 ;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
     65 ;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
     66 ;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
     67 ;stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)
     68 ;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
     69 ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
     70 ;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
     71 ;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
     72 ;stderr_logfile_backups=10     ; # of stderr logfile backups (default 10)
     73 ;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
     74 ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
     75 ;environment=A=1,B=2           ; process environment additions (def no adds)
     76 ;serverurl=AUTO                ; override serverurl computation (childutils)
     77 
     78 ; The below sample eventlistener section shows all possible
     79 ; eventlistener subsection values, create one or more 'real'
     80 ; eventlistener: sections to be able to handle event notifications
     81 ; sent by supervisor.
     82 
     83 ;[eventlistener:theeventlistenername]
     84 ;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
     85 ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
     86 ;numprocs=1                    ; number of processes copies to start (def 1)
     87 ;events=EVENT                  ; event notif. types to subscribe to (req'd)
     88 ;buffer_size=10                ; event buffer queue size (default 10)
     89 ;directory=/tmp                ; directory to cwd to before exec (def no cwd)
     90 ;umask=022                     ; umask for process (default None)
     91 ;priority=-1                   ; the relative start priority (default -1)
     92 ;autostart=true                ; start at supervisord start (default: true)
     93 ;autorestart=unexpected        ; restart at unexpected quit (default: unexpected)
     94 ;startsecs=10                  ; number of secs prog must stay running (def. 1)
     95 ;startretries=3                ; max # of serial start failures (default 3)
     96 ;exitcodes=0,2                 ; 'expected' exit codes for process (default 0,2)
     97 ;stopsignal=QUIT               ; signal used to kill process (default TERM)
     98 ;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
     99 ;user=chrism                   ; setuid to this UNIX account to run the program
    100 ;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
    101 ;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
    102 ;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    103 ;stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)
    104 ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
    105 ;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
    106 ;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    107 ;stderr_logfile_backups        ; # of stderr logfile backups (default 10)
    108 ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
    109 ;environment=A=1,B=2           ; process environment additions
    110 ;serverurl=AUTO                ; override serverurl computation (childutils)
    111 
    112 ; The below sample group section shows all possible group values,
    113 ; create one or more 'real' group: sections to create "heterogeneous"
    114 ; process groups.
    115 
    116 ;[group:thegroupname]
    117 ;programs=progname1,progname2  ; each refers to 'x' in [program:x] definitions
    118 ;priority=999                  ; the relative start priority (default 999)
    119 
    120 ; The [include] section can just contain the "files" setting.  This
    121 ; setting can list multiple files (separated by whitespace or
    122 ; newlines).  It can also contain wildcards.  The filenames are
    123 ; interpreted as relative to this file.  Included files *cannot*
    124 ; include files themselves.

    Django服务配置

    # TCP socket used by Nginx backend upstream
    socket=tcp://localhost:8000
    
    # Directory where your site's project files are located
    directory=/usr/local/ywcontrol
    
    # Each process needs to have a separate socket file, so we use process_num
    # Make sure to update "mysite.asgi" to match your project name
    command=daphne -u /run/daphne/daphne%(process_num)d.sock --fd 0  --access-log - --proxy-headers ywcontrol.asgi:application
    
    # Number of processes to startup, roughly the number of CPUs you have
    numprocs=4
    
    # Give each process a unique name so they can be told apart
    process_name=asgi%(process_num)d
    
    # Automatically start and recover processes
    autostart=true
    autorestart=true
    
    # Choose where you want your log to go
    stdout_logfile=/var/log/asgi.log
    redirect_stderr=true
  • 相关阅读:
    英语语法最终珍藏版笔记-16定语从句
    U3D-页游-检测机制-webplayer-调试方法
    Unity UGUI 的RectTransform参数的设置
    游戏贴图的基本知识
    游戏贴图与模型基本规范
    【游戏模型】游戏超写实贴图制作技巧
    灯光下角度不同会出现中间的片没有光照
    Unity3d中SendMessage 用法
    C# Hashtable赋值给另一个Hashtable时
    InvalidOperationException: out of sync
  • 原文地址:https://www.cnblogs.com/changbo/p/15169088.html
Copyright © 2020-2023  润新知