在Debian上发生服务器崩溃后,uWSGI突然无法重启

时间:2014-11-16 14:28:02

标签: linux nginx webserver debian uwsgi

我的服务器崩溃后,我无法再次启动uWSGI,并继续在unlink()bind()上收到错误。

我以root身份开始我的服务,所以它更奇怪。

Sun Nov 16 15:25:24 2014 - *** Starting uWSGI 1.2.3-debian (64bit) on [Sun Nov 16 15:25:24 2014] ***
Sun Nov 16 15:25:24 2014 - compiled with version: 4.7.2 on 06 July 2013 12:20:09
Sun Nov 16 15:25:24 2014 - detected number of CPU cores: 1
Sun Nov 16 15:25:24 2014 - current working directory: /
Sun Nov 16 15:25:24 2014 - writing pidfile to /run/uwsgi/app/myserver_dev/pid
Sun Nov 16 15:25:24 2014 - detected binary path: /usr/bin/uwsgi-core
Sun Nov 16 15:25:24 2014 - setgid() to 33
Sun Nov 16 15:25:24 2014 - setuid() to 33
Sun Nov 16 15:25:24 2014 - writing pidfile to /var/www/servers/myserver/development/logs/myserver.pid
Sun Nov 16 15:25:24 2014 - your memory page size is 4096 bytes
Sun Nov 16 15:25:24 2014 - detected max file descriptor number: 1024
Sun Nov 16 15:25:24 2014 - lock engine: pthread robust mutexes
Sun Nov 16 15:25:24 2014 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/myserver_dev/socket fd 3
Sun Nov 16 15:25:24 2014 - unlink(): Permission denied [socket.c line 75]
Sun Nov 16 15:25:24 2014 - bind(): Address already in use [socket.c line 107]

nginx服务器:

server {
    access_log      /var/www/servers/example/development/logs/nginx_access.log;
    error_log       /var/www/servers/example/development/logs/nginx_error.log;
    listen          8181;
    server_name     example.com;
    charset         utf-8;
}

server {
    listen  80;
    server_name *.example.com;
    return 301 http://example.com$request_uri;
}

server {
    access_log      /var/www/servers/example/production/logs/nginx_access.log;
    error_log       /var/www/servers/example/production/logs/nginx_error.log;
    listen          80;
    server_name     example.com;
    charset         utf-8;    
}

server {
    listen          7777;
    server_name     example.com;
    charset         utf-8;
    root            /var/www/servers/phpmyadmin;
    index           index.php   index.html  index.htm;

    if (!-e $request_filename) {
        rewrite ^/(.+)$ /index.php?url=$1 last;
        break;
    }

    location ~ .php$ {
        allow       2.110.234.34;
        deny        all;
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
    }
}

uWSGI配置开发:

[uwsgi]
master = true
workers = 2
socket = /var/www/servers/example/development/sockets/example.sock
chmod-socket = 666
log-date = true
uid = www-data
gid = www-data
chdir = /var/www/servers/example/development/webapp
wsgi-file = /var/www/servers/example/development/webapp/webapp/wsgi.py
virtualenv = /var/www/servers/example/development/env
vacuum = true
env = DJANGO_SETTINGS_MODULE=webapp.settings
pidfile2 = /var/www/servers/example/development/logs/example.pid

uWSGI配置生产

[uwsgi]
master = true
workers = 2
socket = /var/www/servers/example/production/sockets/example.sock
chmod-socket = 666
log-date = true
uid = www-data
gid = www-data
chdir = /var/www/servers/example/production/webapp
wsgi-file = /var/www/servers/example/production/webapp/webapp/wsgi.py
virtualenv = /var/www/servers/example/production/env
vacuum = true
env = DJANGO_SETTINGS_MODULE=webapp.settings
pidfile2 = /var/www/servers/example/production/logs/example.pid

1 个答案:

答案 0 :(得分:2)

虽然您以root用户身份运行服务器但它将权限降低到33(可能是www-data)。此用户(33)必须拥有删除/var/www/servers/example/production/sockets/example.sock的权利。

崩溃可能会破坏现在具有错误属性的inode。修复它们,它应该再次工作。