2016-10-27 4 views
0

aws beanstalkでpython(3.4)フラスコアプリを実行しています。 ec2シェルにログインして、フラスコアプリをローカルで実行しようとすると、正しく実行され、リモートcassandraからデータが取得されます。しかし、cassandraからデータを取得している間、AWS ebによって実行されるアプリは、httpd/error_logに次のエラーを投げかけます。AWS beanstalkで動作しているFlaskアプリがリモートのcassandraに接続できません

ERROR in app: Exception on /user/1003 [GET] 
Traceback (most recent call last): 
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1988, in wsgi_app 
response = self.full_dispatch_request() 
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1641, in full_dispatch_request 
rv = self.handle_user_exception(e) 
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1544, in handle_user_exception 
reraise(exc_type, exc_value, tb) 
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise 
raise value 
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1639, in full_dispatch_request 
rv = self.dispatch_request() 
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1625, in dispatch_request 
return self.view_functions[rule.endpoint](**req.view_args) 
File "/opt/python/current/app/application.py", line 53, in user_profile 
data = get_user_data(id) 
File "/opt/python/current/app/application.py", line 163, in get_user_data 
if obj: 
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 393, in __le 
n__ 
self._execute_query() 
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 428, in _exe 
cute_query 
self._result_generator = (i for i in self._execute(self._select_query())) 
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 360, in _exe 
cute 
result = _execute_statement(self.model, statement, self._consistency, self._timeout) 
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 1412, in _ex 
ecute_statement 
parts = model._routing_key_from_values(key_values, connection.get_cluster().protocol_version) 
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/connection.py", line 183, in 
get_cluster 
raise CQLEngineException("%s.cluster is not configured. Call one of the setup or default functions firs 
t." % __name__) 
cassandra.cqlengine.CQLEngineException: cassandra.cqlengine.connection.cluster is not configured. Call one 
of the setup or default functions first. 

マイENV:

(venv)[[email protected] ~]$ pip freeze 
cassandra-driver==3.6.0 
click==6.6 
Cython==0.24.1 
Flask==0.11 
itsdangerous==0.24 
Jinja2==2.8 
MarkupSafe==0.23 
six==1.10.0 
Werkzeug==0.11.11 
xmltodict==0.10.2 

よろしく

答えて

0

あなたが最初のセットアップカサンドラへの接続をしませんでした。これに対してクエリを実行するには、これを行う必要があります。

+0

__name__ == "__main__" 場合は実際に私は自分のアプリケーションの主な機能には次の操作を行います。 connection.setup([config.CASSANDRA_CLUSTER_IP]、config.CONST_KEYSPACE、PROTOCOL_VERSION = 3) はos.environ [ "CQLENG_ALLOW_SCHEMA_MANAGEMENT"] = "はい " sync_table(mytable) – VaibhavJain

+0

env varは設定されていますか? –

+0

私の悪い。私は__main__関数で接続を設定していました。 Elastic BeanstalkのAWS設定は、WSGI環境(バックエンドのApache + WSGI)を設定します。それがEB環境で実行されていたとき、主な機能が呼び出されていました。私は主要な機能の外に接続コードを移動し、それは働き始めた。 – VaibhavJain

関連する問題