I'm new on flask/python dev but I need to use Powerdns-admin for my public DNS. This work with flask and i need to use supervisor to start the web panel of powerdns-admin. I think I made few mistakes on directory or launching flask.
This is my /opt/powerdns-admin/run.py
#!/usr/bin/env python
from app import app
from config import PORT
try:
from config import BIND_ADDRESS
except:
BIND_ADDRESS = '127.0.0.1'
if __name__ == '__main__':
app.run(debug = True, host=BIND_ADDRESS, port=PORT)
Here the 12 first lines of /opt/powerdns-admin/app/init.py
from werkzeug.contrib.fixers import ProxyFix
from flask import Flask, request, session, redirect, url_for
from flask_login import LoginManager
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_object('config')
app.wsgi_app = ProxyFix(app.wsgi_app)
login_manager = LoginManager()
login_manager.init_app(app)
db = SQLAlchemy(app)
And this is my supervisor config
[program:powerdnsadmin]
command = python /opt/powerdns-admin/run.py
directory = /opt/powerdns-admin/app
autostart = true
autorestart = true
stdout_logfile=/var/log/supervisor/program_powerdnsadmin.log
stderr_logfile=/var/log/supervisor/program_powerdnsadmin.error
But when I do a supervisorctl update i got this on the program_powerdnsadmin.error
Traceback (most recent call last):
File "/opt/powerdns-admin/run.py", line 2, in <module>
from app import app
File "/opt/powerdns-admin/app/__init__.py", line 3, in <module>
from flask_login import LoginManager
ImportError: No module named flask_login
However, when I launch the run.py manually it's OK
infra@nameserver:~$ source ./flask/bin/activate
(flask) infra@nameserver:~$ python powerdns-admin/run.py
[INFO] * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
This is few versions :
pip show python
Name: Python
Version: 2.7.12
pip show flask
Name: Flask
Version: 0.11.1
pip show flask_login
Name: Flask-Login
Version: 0.3.2
I hope the solution is a dumb thing, I'm blocked since 4 days on that :(
Thanks
Your supervisor configuration is launching your system Python instead of your
flask
virtualenv Python.The supervisor command must be:
I'm not sure if the
~
works, maybe you have to expand it.