2016-04-25 66 views
0

Ubuntu-serverの起動時やリブート時に、私のロジックサーバー(Python3 + Django + uwsgi + nginx)を自動実行します。そこで、実行スクリプト(uwsgi --ini=/data/xxx.ini)を書き、/etc/rc.localに追加します。プログラムの印刷ログをファイルにする場合Ubuntuの起動時またはリブート時にDjango Serverが自動的に起動しますか?

はその後、私は、の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開始指揮するとき、それはうまく動作します。

+0

あなたはこのために[監督](http://supervisord.org/)を使用する必要があります。 –

答えて

0

あなたはそれがあなたのために働くだろう、この.SHファイルの再起動cronジョブを作成した仮想アクティベイトコード

#!/bin/bash 
clear 
cd /path/to your/virtual environment #path to your virtual environment 
. bin/activate #Activate your virtual environment 
cd /path/to your/project directory 
python manage.py runserver #run django server 

と.SHファイルを記述する必要があります。

チェック詳細については、このlink ...

関連する問題