我遇到了Django没有像它应该的那样滚动日志的问题。在我的httpd错误日志中,我看到了许多如下语句:
[Tue Sep 16 14:52:05.952416 2014] [wsgi:error] [pid 4420:tid 139708516480768] Traceback (most recent call last):
[Tue Sep 16 14:52:05.952527 2014] [wsgi:error] [pid 4420:tid 139708516480768] File "/usr/local/lib/python2.7/logging/handlers.py", line 77, in emit
[Tue Sep 16 14:52:05.952619 2014] [wsgi:error] [pid 4420:tid 139708516480768] self.doRollover()
[Tue Sep 16 14:52:05.952646 2014] [wsgi:error] [pid 4420:tid 139708516480768] File "/usr/local/lib/python2.7/logging/handlers.py", line 142, in doRollover
[Tue Sep 16 14:52:05.952674 2014] [wsgi:error] [pid 4420:tid 139708516480768] os.rename(self.baseFilename, dfn)
[Tue Sep 16 14:52:05.952692 2014] [wsgi:error] [pid 4420:tid 139708516480768] OSError: [Errno 26] Text file busy
[Tue Sep 16 14:52:05.952731 2014] [wsgi:error] [pid 4420:tid 139708516480768] Logged from file constraint_calculations.py, line 97
我在一个运行centos6.5的流浪箱上,在mod wsgi下运行django,通过WSGIDaemonProcess directive运行25个线程。在
发生错误时应用程序日志目录的内容如下。我的日志配置指定4个备份。我不确定只剩下#4和当前文件是否意味着什么。在
^{pr2}$当我运行httpd时,下面是我看到的进程列表。在
[root@localhost fact]# ps aux | grep httpd
root 5565 0.0 0.1 101228 2832 ? Ss 16:22 0:00 /usr/sbin/httpd
fact 5567 0.3 0.3 511280 7660 ? Sl 16:22 0:00 /usr/sbin/httpd
daemon 5568 0.3 0.4 447620 8060 ? Sl 16:22 0:00 /usr/sbin/httpd
daemon 5569 0.3 0.4 447620 8064 ? Sl 16:22 0:00 /usr/sbin/httpd
daemon 5570 0.3 0.4 447620 8068 ? Sl 16:22 0:00 /usr/sbin/httpd
root 5680 0.0 0.0 103248 816 pts/1 S+ 16:22 0:00 grep httpd
应用程序日志(而不是httpd错误日志)位于VirtualBox共享目录中。我检查了每个this suggestion(通过命令watch -n 1 lsof logs/project-all.log
)访问这些文件的进程,但是即使Django抛出错误,这个命令也表明访问日志文件的唯一进程是httpd本身。在
我知道文件权限是一个常见的罪魁祸首,但是httpd和wsgi进程都是以同一个用户(fact
)的身份运行的,并且该用户对日志目录拥有完全的写和执行权限。在
根据Graham's comment,以下是我认为相关的mod\u wsgi配置指令:
# Outside the VirtualHost definition
WSGIDaemonProcess site-1 user=fact group=fact threads=25 python-path=/usr/local/lib/python2.7/site-packages:/var/fact
# Inside the VirtualHost definition
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /var/fact/fact-conf/wsgi/fact.wsgi
WSGIProcessGroup site-1
<Directory /var/fact/fact-conf/wsgi>
Require all granted
</Directory>
目前没有回答
相关问题 更多 >
编程相关推荐