AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[supervisord](server)

Martin Hope
Gaetan GR
Asked: 2021-12-29 10:38:06 +0800 CST

主管没有使用 Django 项目正确重新加载 Gunicorn

  • 1

在将Django项目推向生产时,我正在使用Supervisor重新加载Gunicorn :

工作流程:

          " && python manage.py migrate"\
          " && python manage.py collectstatic --noinput"\
          " && supervisorctl restart frontdesk-gunicorn"\
          " && exit"

主管配置:

   [program:project-gunicorn]
    command=/home/gaetangr/project/myprojectenv/bin/gunicorn config.wsgi:application
    user = gaetangr
    directory = /home/gaetangr/project
    autostart = true
    autorestart = true

但大多数时候,为了传播所有的变化,我必须做一个 sudo :

systemctl restart gunicorn

据我了解,主管的命令应该完全相同。

任何想法 ?

linux ubuntu django gunicorn supervisord
  • 1 个回答
  • 292 Views
Martin Hope
Paul
Asked: 2021-08-07 04:47:32 +0800 CST

如何使用 Supervisor(包括 Gunicorn 和 Nginx)设置多个 Django 应用程序?bind() to [::]:8090 失败(98:地址已在使用中)

  • 1

我已经使用 Supervisor、Gunicorn 和 Nginx(在 Debian Buster 上)部署了一个 Django/Wagtail 应用程序,所以我可以通过http://xx.xxx.xxx.xxx:8090访问它。

/etc/nginx/sites-available/cms

server {
    server_name xx.xxx.xxx.xxx;
    listen 8090;
    listen [::]:8090 ipv6only=on;
    error_log /home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/var/log/gunicorn-error.log;
    access_log /home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/var/log/gunicorn-access.log;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/www.mysite.com/www/my-site/cms/admin_panel;
    }
        location /media/ {
        root /home/www.mysite.com/www/my-site/cms/admin_panel;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/run/gunicorn.sock;
    }
}
/etc/supervisor/conf.d/guni-mysite-admin.conf

[program:guni-mysite-admin]
command=/home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/bin/gunicorn admin_panel.wsgi:application --config /home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/etc/gunicorn/conf.py
user=www.mysite.com
autostart=true
autorestart=true
/etc/supervisor/conf.d/nginx-mysite-admin.conf

[program:nginx-mysite-admin]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
stderr_logfile=/home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/var/log/nginx-error.log
stdout_logfile=/home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/var/log/nginx-access.log
stderr_logfile_maxbytes=2MB
stdout_logfile_maxbytes=2MB
/home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/etc/gunicorn/conf.py

workers = 3
keepalive = 5
user = 'www.mysite.com'
proc_name = 'admin_panel'
loglevel = 'error'
errorlog = '/home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/var/log/gunicorn-error.log'
accesslog = '/home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/var/log/gunicorn-access.log'
bind = 'unix:/home/www.mysite.com/.local/share/virtualenvs/cms-WqsZ9qOt/run/gunicorn.sock'
raw_env = ['DJANGO_SETTINGS_MODULE=admin_panel.settings.production']
pythonpath = '/home/www.mysite.com/www/mysite/cms/admin_panel'

现在我以同样的方式添加了另外 2 个 Django 应用程序。不幸的是,主管无法提出他们。有时 3 次运行中有 1 次运行,但大多数时候它们都不起作用。如果它有效,它会创建 3 个进程(idk,如果它应该是这样的话)。

$ sudo lsof -i:8090

COMMAND  PID     USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
nginx   3631     root   16u  IPv4 961301189      0t0  TCP *:8090 (LISTEN)
nginx   3631     root   17u  IPv6 961301190      0t0  TCP *:8090 (LISTEN)
nginx   3632 www-data   16u  IPv4 961301189      0t0  TCP *:8090 (LISTEN)
nginx   3632 www-data   17u  IPv6 961301190      0t0  TCP *:8090 (LISTEN)
nginx   3633 www-data   16u  IPv4 961301189      0t0  TCP *:8090 (LISTEN)
nginx   3633 www-data   17u  IPv6 961301190      0t0  TCP *:8090 (LISTEN)

Nginx 错误日志给出98: Address already in use,即使在端口 81 上(将其作为默认端口,因为 Apache 正在使用 80),未使用。Apache 应该不是问题,因为它不起作用,即使 Apache 已关闭。

/var/log/nginx/error.log

...
2021/08/06 12:41:54 [emerg] 24927#24927: bind() to [::]:4020 failed (98: Address already in use)
2021/08/06 12:41:54 [emerg] 24927#24927: bind() to [::]:8090 failed (98: Address already in use)
2021/08/06 12:41:54 [emerg] 24927#24927: bind() to [::]:81 failed (98: Address already in use)
2021/08/06 12:41:54 [emerg] 24927#24927: bind() to [::]:8070 failed (98: Address already in use)
2021/08/06 12:41:54 [emerg] 24927#24927: bind() to [::]:8080 failed (98: Address already in use)
2021/08/06 12:41:54 [emerg] 24927#24927: bind() to [::]:4030 failed (98: Address already in use)
2021/08/06 12:41:54 [emerg] 24928#24928: still could not bind()
...

输出 - # nginx -T

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#   server {
#       listen     localhost:110;
#       protocol   pop3;
#       proxy      on;
#   }
#
#   server {
#       listen     localhost:143;
#       protocol   imap;
#       proxy      on;
#   }
#}

# configuration file /etc/nginx/modules-enabled/50-mod-http-auth-pam.conf:
load_module modules/ngx_http_auth_pam_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-dav-ext.conf:
load_module modules/ngx_http_dav_ext_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-echo.conf:
load_module modules/ngx_http_echo_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-geoip.conf:
load_module modules/ngx_http_geoip_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-image-filter.conf:
load_module modules/ngx_http_image_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-subs-filter.conf:
load_module modules/ngx_http_subs_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-upstream-fair.conf:
load_module modules/ngx_http_upstream_fair_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-xslt-filter.conf:
load_module modules/ngx_http_xslt_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-mail.conf:
load_module modules/ngx_mail_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-stream.conf:
load_module modules/ngx_stream_module.so;

# configuration file /etc/nginx/mime.types:

types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/javascript                js;
    application/atom+xml                  atom;
    application/rss+xml                   rss;

    text/mathml                           mml;
    text/plain                            txt;
    text/vnd.sun.j2me.app-descriptor      jad;
    text/vnd.wap.wml                      wml;
    text/x-component                      htc;

    image/png                             png;
    image/tiff                            tif tiff;
    image/vnd.wap.wbmp                    wbmp;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/x-ms-bmp                        bmp;
    image/svg+xml                         svg svgz;
    image/webp                            webp;

    application/font-woff                 woff;
    application/java-archive              jar war ear;
    application/json                      json;
    application/mac-binhex40              hqx;
    application/msword                    doc;
    application/pdf                       pdf;
    application/postscript                ps eps ai;
    application/rtf                       rtf;
    application/vnd.apple.mpegurl         m3u8;
    application/vnd.ms-excel              xls;
    application/vnd.ms-fontobject         eot;
    application/vnd.ms-powerpoint         ppt;
    application/vnd.wap.wmlc              wmlc;
    application/vnd.google-earth.kml+xml  kml;
    application/vnd.google-earth.kmz      kmz;
    application/x-7z-compressed           7z;
    application/x-cocoa                   cco;
    application/x-java-archive-diff       jardiff;
    application/x-java-jnlp-file          jnlp;
    application/x-makeself                run;
    application/x-perl                    pl pm;
    application/x-pilot                   prc pdb;
    application/x-rar-compressed          rar;
    application/x-redhat-package-manager  rpm;
    application/x-sea                     sea;
    application/x-shockwave-flash         swf;
    application/x-stuffit                 sit;
    application/x-tcl                     tcl tk;
    application/x-x509-ca-cert            der pem crt;
    application/x-xpinstall               xpi;
    application/xhtml+xml                 xhtml;
    application/xspf+xml                  xspf;
    application/zip                       zip;

    application/octet-stream              bin exe dll;
    application/octet-stream              deb;
    application/octet-stream              dmg;
    application/octet-stream              iso img;
    application/octet-stream              msi msp msm;

    application/vnd.openxmlformats-officedocument.wordprocessingml.document    docx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet          xlsx;
    application/vnd.openxmlformats-officedocument.presentationml.presentation  pptx;

    audio/midi                            mid midi kar;
    audio/mpeg                            mp3;
    audio/ogg                             ogg;
    audio/x-m4a                           m4a;
    audio/x-realaudio                     ra;

    video/3gpp                            3gpp 3gp;
    video/mp2t                            ts;
    video/mp4                             mp4;
    video/mpeg                            mpeg mpg;
    video/quicktime                       mov;
    video/webm                            webm;
    video/x-flv                           flv;
    video/x-m4v                           m4v;
    video/x-mng                           mng;
    video/x-ms-asf                        asx asf;
    video/x-ms-wmv                        wmv;
    video/x-msvideo                       avi;
}

# configuration file /etc/nginx/conf.d/timeout.conf:
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

# configuration file /etc/nginx/sites-enabled/admin.mysite_2:
server {
    server_name xx.xxx.xxx.xxx;
    listen 4020;
    listen [::]:4020 ipv6only=on;
    error_log /home/www.mysite_2/.local/share/virtualenvs/cms-CiomF2CE/var/log/gunicorn-error.log;
    access_log /home/www.mysite_2/.local/share/virtualenvs/cms-CiomF2CE/var/log/gunicorn-access.log;

    # add_header 'Access-Control-Allow-Origin' '*';
    # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/mysite_2/www/translator-app-python/cms/wagtail_cms;
    }
        location /media/ {
        root /home/mysite_2/www/translator-app-python/cms/wagtail_cms;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/mysite_2/.local/share/virtualenvs/cms-CiomF2CE/run/gunicorn.sock;
    }
}
# configuration file /etc/nginx/proxy_params:
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# configuration file /etc/nginx/sites-enabled/cms:
server {
    server_name xx.xxx.xxx.xxx;
    listen 8090;
    listen [::]:8090 ipv6only=on;
    error_log /home/mysite_1/.local/share/virtualenvs/cms-WqsZ9qOt/var/log/gunicorn-error.log;
    access_log /home/mysite_1/.local/share/virtualenvs/cms-WqsZ9qOt/var/log/gunicorn-access.log;

    # add_header 'Access-Control-Allow-Origin' '*';
    # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/mysite_1/www/kc-site/cms/admin_panel;
    }
        location /media/ {
        root /home/wmysite_1/www/kc-site/cms/admin_panel;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/mysite_1/.local/share/virtualenvs/cms-WqsZ9qOt/run/gunicorn.sock;
    }
}
# configuration file /etc/nginx/sites-enabled/default:
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
    # alte Syntax
    listen 81 default_server;
    listen [::]:81 ipv6only=on default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html/Nginx;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html index.php ;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

    # pass PHP scripts to FastCGI server ( neu )
    #
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        include /etc/nginx/conf.d/*.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    # pass PHP scripts to FastCGI server
    #
    #location ~ \.php$ {
    #   include snippets/fastcgi-php.conf;
    #
    #   # With php-fpm (or other unix sockets):
    #   fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    #   # With php-cgi (or other tcp sockets):
    #   # fastcgi_pass 127.0.0.1:9000;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#   listen 80;
#   listen [::]:80;
#
#   server_name example.com;
#
#   root /var/www/example.com;
#   index index.html;
#
#   location / {
#       try_files $uri $uri/ =404;
#   }
#}

# configuration file /etc/nginx/snippets/fastcgi-php.conf:
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+?\.php)(/.*)$;

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
include fastcgi.conf;

# configuration file /etc/nginx/fastcgi.conf:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

# configuration file /etc/nginx/sites-enabled/kcanalytics:
server {
    server_name xx.xxx.xxx.xxx;
    listen 8070;
    listen [::]:8070 ipv6only=on;
    root /home/mysite_1/www/kc-site/Open-Web-Analytics;
    index index.php index.html index.htm;
    location / {
        try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        include /etc/nginx/conf.d/*.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }
    error_log /var/log/nginx/kcanalyticslog/kcanalytics-error.log;
    access_log /var/log/nginx/kcanalyticslog/kcanalytics-access.log;
}

# configuration file /etc/nginx/sites-enabled/kcclient:
server {
    server_name xx.xxx.xxx.xxx;
    listen 8080;
    listen [::]:8080 ipv6only=on;
    root /var/www/html/Nginx;
    index index.nginx-debian.html;

    location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    }
}

# configuration file /etc/nginx/sites-enabled/phrases-api.mysite_2:
server {
    server_name xx.xxx.xxx.xxx;
    listen 4030;
    listen [::]:4030 ipv6only=on;
    error_log /home/mysite_2/.local/share/virtualenvs/api-dAF0CRIW/var/log/gunicorn-error.log;
    access_log /home/mysite_2/.local/share/virtualenvs/api-dAF0CRIW/var/log/gunicorn-access.log;

    # add_header 'Access-Control-Allow-Origin' '*';
    # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/mysite_2/www/translator-app-python/api/translator_rest_api;
    }
        location /media/ {
        root /home/mysite_2/www/translator-app-python/api/translator_rest_api;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/mysite_2/.local/share/virtualenvs/api-dAF0CRIW/run/gunicorn.sock;
    }
}
linux django nginx gunicorn supervisord
  • 1 个回答
  • 225 Views
Martin Hope
Guerrilla
Asked: 2021-02-21 21:30:49 +0800 CST

Supervisord 服务未输出到 docker-compose 控制台

  • 0

我有一个 docker 容器,它在其中运行多个服务。我希望每个服务都将其输出发送到控制台。这是一个开发容器,所以我想在工作时查看所有输出。

我试过这个文件:

[supervisord]
nodaemon=true
 
[program:sshd]
command=/usr/sbin/sshd -D
autostart=true
autorestart=true
 
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
priority=900
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
username=www-data
autorestart=true
autostart=true

[program:php-fpm]
command=/usr/sbin/php-fpm7.4 -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
priority=5


[program:memcached]
command=/usr/bin/memcached -u root
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
priority=200

但它只输出supervisord消息,而不是来自服务的消息。我看到另一个线程向其中发送日志消息,/dev/fd/1所以我也尝试了,但没有成功。

stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

我的基础镜像是 ubuntu 20.04。

为什么我不能将服务日志消息输入控制台?

docker supervisord stdout
  • 1 个回答
  • 1891 Views
Martin Hope
Philipp Mochine
Asked: 2020-08-18 04:07:29 +0800 CST

supervisord:你能在不同的命令路径上运行两个同名的程序吗?

  • 0

当我创建两个文件时:

地平线-staging.conf

[program:horizon]
process_name=%(program_name)s
command=php /var/www/staging/current/artisan horizon
autostart=true
autorestart=true
user=forge
redirect_stderr=true

地平线生产.conf

[program:horizon]
process_name=%(program_name)s
command=php /var/www/production/current/artisan horizon
autostart=true
autorestart=true
user=forge
redirect_stderr=true

并发射命令sudo supervisorctl start horizon。它运行这两个程序吗?(附带问题,我可以把它也放在一个 conf 文件中吗?)

supervisord
  • 1 个回答
  • 718 Views
Martin Hope
Syntax
Asked: 2017-04-07 19:47:10 +0800 CST

监督日志;如何为每次执行将日志消息分离到一个新文件中?

  • 0

我正在使用supervisord来保持我们的应用程序服务器服务在失败时保持活动状态,并在机器负载时自动启动服务。

目前所有日志都进入同一个长时间运行的文件,这在尝试对故障进行分类时很痛苦。我希望日志文件在程序执行/重新启动时是不同的。

我找不到任何用于分离日志内容的配置,除了设置文件最大大小,它会创建一个新文件并可能根据您的配置保留旧文件;这在我正在寻找的执行之间没有清晰的分离。

非常感谢任何帮助或想法。

supervisord
  • 1 个回答
  • 425 Views
Martin Hope
uberrebu
Asked: 2017-03-13 12:12:31 +0800 CST

如何使用 supervisord 重新启动 php7-fpm?

  • 0

我有一个用于 apache 和 php7-fpm 的自定义 docker 映像,但是每当我对 php ini 文件进行更改并在映像构建期间的这些更改之后使用 supervisord 重新启动 php7-fpm,然后从映像运行容器之前,我注意到我一直无法使 php7-fpm 重新启动。所以我对 php ini 文件所做的更改永远不会得到反映

但是当我登录到正在运行的容器并尝试重新启动 php7-fpm 时,我会看到这些更改

这是我的supervisord配置

[supervisord]
nodaemon=true

[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 -c /etc/php/7.0/fpm/php-fpm.conf
autorestart=true

[program:apache2]
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
autorestart=true

这是我的 start.sh 脚本

#!/bin/bash
set -e
echo "ServerName localhost" >> /etc/apache2/apache2.conf
#echo "export HOSTNAME=$(hostname)" >> /etc/apache2/envvars
sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
sed -i -e "s/;short_open_tag = Off/short_open_tag = On/g" /etc/php/7.0/fpm/php.ini
sed -i -e "s/;display_errors = Off/display_errors = On/g" /etc/php/7.0/fpm/php.ini
sed -ri 's/^upload_max_filesize\s*=\s*.+/upload_max_filesize = 450M/g' /etc/php/7.0/fpm/php.ini
sed -ri 's/^max_input_time\s*=\s*.+/max_input_time = 300/g' /etc/php/7.0/fpm/php.ini
sed -ri 's/^memory_limit\s*=\s*.+/memory_limit = 640M/g' /etc/php/7.0/fpm/php.ini
sed -ri 's/^post_max_size\s*=\s*.+/post_max_size = 450M/g' /etc/php/7.0/fpm/php.ini
sed -ri 's/^max_execution_time\s*=\s*.+/max_execution_time = 300/g' /etc/php/7.0/fpm/php.ini
sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php/7.0/fpm/php-fpm.conf
sed -i -e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.max_children = 5/pm.max_children = 9/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.start_servers = 2/pm.start_servers = 3/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.min_spare_servers = 1/pm.min_spare_servers = 2/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.max_spare_servers = 3/pm.max_spare_servers = 4/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/pm.max_requests = 500/pm.max_requests = 200/g" /etc/php/7.0/fpm/pool.d/www.conf
sed -i -e "s/;clear_env = no/clear_env = no/g" /etc/php/7.0/fpm/pool.d/www.conf

请帮助如何在创建 docker 映像时使用脚本对 php ini 文件进行更改时重新启动php7-fpmstart.sh

附言

您可能想知道为什么我只需要启动 php7-fpm 就需要重新启动它,没有办法让 php7-fpm 与 docker 一起工作,除非我实际上首先在我的 docker 文件中启动它,如下所示。每当我从 dockerfile 中删除该行时,它都不起作用。如果有人在 docker 中有 apache 2.4 和 php7-fpm 设置,但没有这种方式,请给我发送他们图像的链接!

RUN service php7.0-fpm start

谢谢

php-fpm docker php7 supervisord
  • 1 个回答
  • 10147 Views
Martin Hope
Matheus Portela
Asked: 2017-01-24 14:14:59 +0800 CST

无法将主管与 Apache Kafka 一起使用

  • 1

我有一台安装了 Apache Kafka 的 Ubuntu 16.04 机器。start_kafka.sh目前,我可以通过使用具有以下内容的脚本使其完美运行:

JMX_PORT=17264 KAFKA_HEAP_OPTS="-Xms1024M -Xmx3072M" /home/kafka/kafka_2.11-0.10.1.0/bin/kafka-server-start.sh -daemon /home/kafka/kafka_2.11-0.10.1.0/config/server.properties

现在,我想使用supervisor它来自动重启进程,如果它失败并在重启机器后立即启动。问题是我无法supervisor启动 Kafka。

我supervisor使用安装pip并将此配置文件放置在/etc/supervisord.conf:

; Supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html

[unix_http_server]
file=/tmp/supervisor.sock   ; (the path to the socket file)

[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           ; (num of main logfile rotation backups;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)
minfds=1024                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)

; 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:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket

[program:kafka]
command=/home/kafka/kafka_2.11-0.10.1.0/start_kafka.sh ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
startsecs=10                   ; # 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,2                 ; 'expected' exit codes used with autorestart (default 0,2)
stopsignal=TERM               ; signal used to kill process (default TERM)
stopwaitsecs=180               ; max num secs to wait b4 SIGKILL (default 10)
stdout_logfile=NONE        ; stdout log path, NONE for none; default AUTO
;environment=A="1",B="2"       ; process environment additions (def no adds)

当我尝试启动 Kafka 时,出现以下错误:

# supervisorctl start kafka
kafka: ERROR (spawn error)

主管日志 (at /tmp/supervisord.log) 包含以下内容:

2017-01-23 22:10:24,532 INFO spawned: 'kafka' with pid 21311
2017-01-23 22:10:24,536 INFO exited: kafka (exit status 127; not expected)
2017-01-23 22:10:25,542 INFO spawned: 'kafka' with pid 21312
2017-01-23 22:10:25,559 INFO exited: kafka (exit status 127; not expected)
2017-01-23 22:10:27,562 INFO spawned: 'kafka' with pid 21313
2017-01-23 22:10:27,567 INFO exited: kafka (exit status 127; not expected)
2017-01-23 22:10:30,571 INFO spawned: 'kafka' with pid 21314
2017-01-23 22:10:30,576 INFO exited: kafka (exit status 127; not expected)
2017-01-23 22:10:31,578 INFO gave up: kafka entered FATAL state, too many start retries too quickly

必须说我已经尝试删除-daemon标志start_kafka.sh以使用supervisor但没有成功。

有人知道发生了什么吗?

ubuntu ubuntu-16.04 kafka supervisord
  • 1 个回答
  • 1261 Views
Martin Hope
krypto07
Asked: 2016-12-08 06:41:15 +0800 CST

设置 Django + nginx + uwsgi + supervisord:/r​​un 与 /tmp 中的套接字之间的区别

  • 1

我正在尝试使用 uWSGI Emperor 和 nginx 在同一台机器上设置 2 个 Django Web 应用程序,并让 supervisord 管理 Emperor 进程的启动和重新启动。在互联网上进行大量搜索后,我终于设法获得了有效的部署。然而,在所有拉扯头发的过程中,我发现了一些奇怪的东西,如果有人能向我解释为什么会发生这种情况,我将不胜感激。

所以我以 root 身份在帝王模式下运行我的 uWSGI 进程。vassal ini 配置文件负责删除我的 uid 的权限并创建一个由我的用户拥有的套接字文件,组为 www-data(以便 nginx 可以写入它)和权限 660。这是一个示例 vassal 配置:

[uwsgi]
uid = xxxx

chdir = %(project_dir)/%(project)
home = %(venv_base)/%(venv)
module = %(project).wsgi:application

master = true
processes = 4

socket = /tmp/%(project).sock
chown-socket = %(uid):www-data
chmod-socket = 660
stats = /tmp/%(project)_stat.sock
logto = %(project_dir)/logs/uwsgi.log
# Cleans up when the process is killed (includes deleting the socket file)
vacuum = true

这工作得很好,但是如果我尝试在 /run 而不是 /tmp 中创建套接字,我开始收到套接字 bind() 调用的权限被拒绝错误。使用适当的所有权和权限可以很好地创建套接字,但 vassal 无法在其上调用 bind() 或 unlink()。为什么会这样?/tmp 和 /run 有什么区别,我应该什么时候使用它们?任何帮助或指示将不胜感激。

编辑:我刚刚尝试将套接字的权限设置为 777 并且 uwsgi 仍然给我一个权限被拒绝错误:(

nginx ubuntu-16.04 uwsgi supervisord
  • 1 个回答
  • 964 Views
Martin Hope
Darakir
Asked: 2016-12-01 02:46:10 +0800 CST

当我通过 Supervisord 运行 MariaDB 时,它一直在退出

  • -1

我正在尝试在 rkt 中设置一个 LEMP 堆栈(使用 Docker 文件),所以我使用 Supervisord 让所有东西都在同一个容器中运行。当我单独构建和启动 Mariadb 容器时,它工作正常。只要我尝试通过 Supervisord 运行它,MariaDB 就会立即退出。我究竟做错了什么?

我也想将 Supervisord 用于其他事情,所以我每次运行它时都会发送它: RUN printf "\n[program:mysqld]\ncommand=sleep 5; mysqld_safe --skip-syslog\nstartretries=10\n" >> /etc/supervisor/conf.d/supervisord.conf

我为测试目的添加了 Sleep 5 和 startretries。

错误日志如下所示:

161130  9:32:25 [Note] InnoDB: Using mutexes to ref count buffer pool pages
161130  9:32:25 [Note] InnoDB: The InnoDB memory heap is disabled
161130  9:32:25 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
161130  9:32:25 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
161130  9:32:25 [Note] InnoDB: Compressed tables use zlib 1.2.8
161130  9:32:25 [Note] InnoDB: Using Linux native AIO
161130  9:32:25 [Note] InnoDB: Using CPU crc32 instructions
161130  9:32:25 [Note] InnoDB: Initializing buffer pool, size = 128.0M
161130  9:32:25 [Note] InnoDB: Completed initialization of buffer pool
161130  9:32:25 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
161130  9:32:25 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
161130  9:32:25 [Note] InnoDB: Database physically writes the file full: wait...
161130  9:32:25 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
161130  9:32:25 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
161130  9:32:26 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
161130  9:32:26 [Warning] InnoDB: New log files created, LSN=45781
161130  9:32:26 [Note] InnoDB: Doublewrite buffer not found: creating new
161130  9:32:26 [Note] InnoDB: Doublewrite buffer created
161130  9:32:26 [Note] InnoDB: 128 rollback segment(s) are active.
161130  9:32:26 [Warning] InnoDB: Creating foreign key constraint system tables.
161130  9:32:26 [Note] InnoDB: Foreign key constraint system tables created
161130  9:32:26 [Note] InnoDB: Creating tablespace and datafile system tables.
161130  9:32:26 [Note] InnoDB: Tablespace and datafile system tables created.
161130  9:32:26 [Note] InnoDB: Creating zip_dict and zip_dict_cols system tables.
161130  9:32:26 [Note] InnoDB: zip_dict and zip_dict_cols system tables created.
161130  9:32:26 [Note] InnoDB: Waiting for purge to start
161130  9:32:26 [Note] InnoDB:  Percona XtraDB (link removed) 5.6.32-79.0 started; log sequence number 0

[这里有很多重复]

161130  9:32:44 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
161130  9:32:45 [Note] InnoDB: Shutdown completed; log sequence number         1623609
161130  9:32:45 [Note] InnoDB: Using mutexes to ref count buffer pool pages
161130  9:32:45 [Note] InnoDB: The InnoDB memory heap is disabled
161130  9:32:45 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
161130  9:32:45 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
161130  9:32:45 [Note] InnoDB: Compressed tables use zlib 1.2.8
161130  9:32:45 [Note] InnoDB: Using Linux native AIO
161130  9:32:45 [Note] InnoDB: Using CPU crc32 instructions
161130  9:32:45 [Note] InnoDB: Initializing buffer pool, size = 128.0M
161130  9:32:45 [Note] InnoDB: Completed initialization of buffer pool
161130  9:32:45 [Note] InnoDB: Highest supported file format is Barracuda.
161130  9:32:45 [Note] InnoDB: 128 rollback segment(s) are active.
161130  9:32:45 [Note] InnoDB: Waiting for purge to start
161130  9:32:46 [Note] InnoDB:  Percona XtraDB (link removed) 5.6.32-79.0 started; log sequence number 1623609
161130  9:32:46 [Note] Plugin 'FEEDBACK' is disabled.
161130  9:32:46 [Note] InnoDB: FTS optimize thread exiting.
161130  9:32:46 [Note] InnoDB: Starting shutdown...
161130  9:32:47 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
161130  9:32:48 [Note] InnoDB: Shutdown completed; log sequence number 1623619

没有一个错误,它只是开始关闭。

想法?

docker mariadb supervisord rkt
  • 1 个回答
  • 823 Views
Martin Hope
Canadian
Asked: 2016-10-13 15:14:05 +0800 CST

缺少主管袜子文件

  • 20

我安装了 Supervisor (v3.1.2) 来管理 ElastAlert 但是当我运行supervisorctl它时有时会抛出这个错误:

unix:///var/run/supervisor.sock no such file

其他时候它会抛出这个错误:

unix:///tmp/supervisor.sock no such file

我会注意到它确实让我进入了supervisor>提示符,但之后的命令与上面的错误相同。该/etc/supervisor/supervisor.conf文件配置为使用/var/run,这似乎与第二个错误不一致。

正如其他帮助页面所建议的那样,我创建了一个指向 的链接/etc/supervisor.conf,但这并没有什么不同。

两件奇怪的事情,当我第一次安装 Supervisor 时,它运行良好,但在重新启动后,这个问题就开始了。另一个奇怪的事情是 ElastAlert 在重新启动后启动,并继续正常执行。因此,虽然它可能有错误,但它正在做它的工作。不是一个展示停止者,但我希望它能够正常工作。

有任何想法吗?

supervisord debian-jessie
  • 7 个回答
  • 54258 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve