2017-08-14 5 views
1

J'ai essayé sans succès d'installer mon application Flask sur un serveur Jelastic. J'ai là Apache 2.4 et Python 3.5. Le problème montre comme 500 Erreur interne du serveur lorsque j'essaie d'accéder à ma page "/".Jelastic Apache + mod_wsgi: l'objet 'module' n'est pas appelable

[point 1.] Lors du redémarrage du serveur Apache, apache2-python: la page d'actions montre quelques valeurs erronées:

Starting Python 2.4 cartridge (Apache+mod_wsgi) 
Application directory /opt/repo/ROOT selected as DocumentRoot 
$OPENSHIFT_PYTHON_WSGI_APPLICATION=/opt/repo//ROOT/application file not found 
    WSGI application was not found 

Je pense que le répertoire d'application devrait être /opt/repo/ROOT/stk_server, que je définis dans /opt/shared/conf/etc/conf.d/openshift.conf:

ServerRoot "/opt/repo/" 
DocumentRoot "/opt/repo/ROOT/stk-server" 
WSGIScriptAlias/"/opt/repo/ROOT/stk_server.wsgi" 

Pourquoi Inutilisable indiquant Apache? (Dans différents manuels ces chemins sont définis dans/etc/apache2/sites disponibles/répertoire, mais l'environnement Jelastic ne pas tel.)

[point] 2. mes /opt/shared/webroot/ROOT/stk_server.wsgi importations de fichiers ma demande /opt/shared/webroot/ROOT/stk_server/hello.py à l'aide de commandes

#!/usr/bin/python 
import sys 
import logging 
logging.basicConfig(stream=sys.stderr) 
sys.path.insert(0,"/opt/repo/ROOT/stk_server") 
import os 
os.chdir("/opt/repo/ROOT/stk_server") 
from stk_server import hello as application 

Le hello.py est comme ceci:

from flask import Flask 
app = Flask(__name__) 

print("Running my hello.py={}.".format(__name__)) 
print("My app={}.".format(app)) 

@app.route("/") 
def hello(): 
    return "Hello, I love Python!" 

if __name__ == "__main__": 
    print ("Starting my hello.__main__") 
    app.run() 

Le error_log montre ces wsgi: erreurs:

Running my hello.py=stk_server.hello. 
My app=<Flask 'stk_server.hello'>. 
[remote 10...:228] mod_wsgi (pid=27564): Exception occurred processing WSGI script '/opt/repo/ROOT/stk_server.wsgi'. 
[remote 10...:228] TypeError: 'module' object is not callable 
[remote 10...:236] mod_wsgi (pid=27565): Exception occurred processing WSGI script '/opt/repo/ROOT/stk_server.wsgi'. 
[remote 10...:236] TypeError: 'module' object is not callable 
[remote 10...:228] mod_wsgi (pid=27564): Exception occurred processing WSGI script '/opt/repo/ROOT/stk_server.wsgi'. 
[remote 10...:228] TypeError: 'module' object is not callable 

Qu'est-ce que cet objet 'module'? La même erreur se produit lorsque le répertoire de projet /opt/shared/webroot/ROOT/stk_server a un fichier __init__.py ou non.

+0

Pourriez-vous s'il vous plaît nous fournir juste un nom d'environnement afin de pouvoir vérifier? – Jelastic

+0

Notre site devrait être http://stk-1.demo.datacenter.fi, si vous voulez dire que –

+0

Merci, nous allons vérifier et vous le faire savoir. – Jelastic

Répondre

0

Nous avons vérifié votre environnement et trouvé une "application" importée incorrecte dans le fichier stk_server.wsgi. Le droit chemin:

from stk_server.hello import app as application 

Avoir une belle journée, Jelastic soutien!

+0

Merci beaucoup! Simple mais pas si facile ... –