【发布时间】:2016-04-25 03:11:07
【问题描述】:
我希望我的逻辑服务器(Python3+Django+uwsgi+nginx)在 Ubuntu 服务器启动或重启时自动运行。所以,我写了一个执行脚本(uwsgi --ini=/data/xxx.ini),并将其添加到/etc/rc.local。
然后,我重新启动服务器,逻辑服务器运行,但是当程序打印日志到文件时,python3 抛出异常:
Traceback (most recent call last):
File "/usr/lib/python3.4/logging/handlers.py", line 73, in emit
logging.FileHandler.emit(self, record)
File "/usr/lib/python3.4/logging/__init__.py", line 1041, in emit
StreamHandler.emit(self, record)
File "/usr/lib/python3.4/logging/__init__.py", line 984, in emit
self.handleError(record)
File "/usr/lib/python3.4/logging/__init__.py", line 915, in handleError
traceback.print_stack(frame, file=sys.stderr)
File "/usr/lib/python3.4/traceback.py", line 286, in print_stack
print_list(extract_stack(_get_stack(f), limit=limit), file=file)
File "/usr/lib/python3.4/traceback.py", line 30, in print_list
print(item, file=file, end="")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 95-100: ordinal not in range(128)
Call stack:
File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/wsgi.py", line 177, in __call__
response = self.get_response(request)
File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "./carwashing/views/decorators.py", line 65, in _require_login_release
json_resp = views(request, user=token_cache.employee, *args, **kwargs)
当我直接手动启动 uwsgi 时,它运行良好。
【问题讨论】:
-
您应该为此使用supervisor。
标签: django python-3.x ubuntu uwsgi