AWS Elastic Beanstalk Django アプリケーション環境を CentOS6.5 上に PyDevを使って構築する(4) いくつかのトラブルシュート

AWS Elastic Beanstalk Django アプリケーション環境を CentOS6.5 上に PyDevを使って構築する(1) Django起動まで

で開発環境を構築した。

いくつかのトラブルシュートを以下に備忘。

1.SignatureDoesNotMatch エラー

1.1 現象

eb start したときなど、に以下のようなエラーが発生する。

  1. SignatureDoesNotMatch. Signature expired: 20150102T071152Z is now earlier than 20150102T133521Z (20150102T134021Z - 5 min.)

1.2 原因と対応

クライアントPCの時間が閾値をこえてずれている。

時間をあわせることで解決。

または、タイムサービスを構成する。NTPがインストールされているか確認。されていなければ、

yum insetall ntp

  1. [root@localhost ~]# rpm -qa ntp
  2. ntp-4.2.6p5-1.el6.centos.i686

インストールされている。

サービスを起動

  1. [root@localhost ~]# service ntpd start
  2. ntpd を起動中:

Level3および5で自動実行されるように構成

  1. [root@localhost ~]# chkconfig --level 3 --level 5 ntpd on
  2. [root@localhost ~]# chkconfig --list ntpd
  3. ntpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off

2.Target WSGI script not found or unable to stat エラーとなる

http://stackoverflow.com/questions/20910461/django-elastic-beanstalk-deploy-showing-404
http://stackoverflow.com/questions/17713871/target-wsgi-script-not-found-or-unable-

2.1 現象

アプリケーションにアクセスするとNot Found エラーとなり、

not_found_err

エラーログには、Target WSGI script not found or unable to stat が記録される。

  1. -------------------------------------
  2. /var/log/httpd/error_log
  3. -------------------------------------
  4. [Sat Jan 03 01:31:28.312782 2015] [:error] [pid 2297] [client 127.0.0.1:35123] Target WSGI script not found or unable to stat: /opt/python/current/app/application.py
  5. [Sat Jan 03 01:31:57.774374 2015] [:error] [pid 2300] [client 172.31.8.41:64447] Target WSGI script not found or unable to stat: /opt/python/current/app/application.py

2.2 原因と対応

これが結構やっかい。。。

この手順で環境構築すると発生しなかった。

原因として、デフォルトの設定値 WSGI Path の設定値は、/application.py のようなのだ。

チュートリアルの手順通り実施した場合、Elastic Beanstalk のアプリケーション設定からSoftware Configuration を確認すると、WSGIPath : application.py) となっている。

wsgi_config_default

しかしながら、実際のアプリケーションの構成は、/myapplication/wsgi.py となっている。

  1. [root@localhost phrase]# tree
  2. .
  3. ├── manage.py
  4. ├── phrase
  5. ├── __init__.py
  6. ├── __init__.pyc
  7. ├── settings.py
  8. ├── settings.pyc
  9. ├── urls.py
  10. ├── urls.pyc
  11. ├── wsgi.py
  12. └── wsgi.pyc
  13. └── requirements.txt

しかし、チュートリアルで.ebextensiions/xxxx.configファイルに記述するのは、、/myapplication/wsgi.py

  1. [root@localhost phrase]# cat .ebextensions/phrase.config
  2. container_commands:
  3. 01_syncdb:
  4. command: "django-admin.py syncdb --noinput"
  5. leader_only: true
  6.  
  7. option_settings:
  8. - namespace: aws:elasticbeanstalk:container:python
  9. option_name: WSGIPath
  10. value: phrase/wsgi.py
  11. - option_name: DJANGO_SETTINGS_MODULE
  12. value: phrase.settings

さらに、.elasticbeanstalk 以下に自動作成される設定値もある。

  1. [root@localhost phrase]# cat .elasticbeanstalk/optionsettings.phrase-env
  2. :(略)
  3. [aws:elasticbeanstalk:container:python]
  4. NumProcesses=1
  5. NumThreads=15
  6. StaticFiles=/static/=static/
  7. WSGIPath=phrase/wsgi.py

チュートリアルとは異なる手順で設定を行ったので、このファイルでは、WSGIPath=phrase/wsgi.py となっているが、チュートリアルと同様の手順で実施すると、ここは WSGIPath=application.py となっていた。

ということで、実際は解決策を実施したわけではないが、おそらく上記の2ファイル( .ebextensions/xxxx.config,.elasticbeanstalk/optionsettings.phrase-env ) の WSGIPathの設定を修正した上で、git commit -a を実施(.ebextensions/xxxx.config は git リポジトリの対象)した上で、環境の更新とGitリポジトリからデプロイを実施すれば解決するのではないかと推測できる。

  1. (virtualenv)[piroto@localhost phrase]$ eb update
  2. (virtualenv)[piroto@localhost phrase]$ git aws.push

Follow me!

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です