Move statistics to the start.sh script for clarity

master
kaiyou 7 years ago
parent 8cab079af6
commit 2427544972

@ -55,20 +55,6 @@ db = flask_sqlalchemy.SQLAlchemy(app)
migrate = flask_migrate.Migrate(app, db) migrate = flask_migrate.Migrate(app, db)
limiter = flask_limiter.Limiter(app, key_func=lambda: current_user.username) limiter = flask_limiter.Limiter(app, key_func=lambda: current_user.username)
# Run statistics
if os.path.isfile(app.config["INSTANCE_ID_PATH"]):
with open(app.config["INSTANCE_ID_PATH"], "r") as handle:
instance_id = handle.read()
else:
instance_id = str(uuid.uuid4())
with open(app.config["INSTANCE_ID_PATH"], "w") as handle:
handle.write(instance_id)
if app.config["DISABLE_STATISTICS"].lower() != "true":
try:
socket.gethostbyname(app.config["STATS_ENDPOINT"].format(instance_id))
except:
pass
# Debugging toolbar # Debugging toolbar
if app.config.get("DEBUG"): if app.config.get("DEBUG"):
import flask_debugtoolbar import flask_debugtoolbar

@ -1,5 +1,27 @@
from mailu import app, manager, db, models from mailu import app, manager, db, models
import os
import socket
import uuid
@manager.command
def advertise():
""" Advertise this server against statistic services.
"""
if os.path.isfile(app.config["INSTANCE_ID_PATH"]):
with open(app.config["INSTANCE_ID_PATH"], "r") as handle:
instance_id = handle.read()
else:
instance_id = str(uuid.uuid4())
with open(app.config["INSTANCE_ID_PATH"], "w") as handle:
handle.write(instance_id)
if app.config["DISABLE_STATISTICS"].lower() != "true":
try:
socket.gethostbyname(app.config["STATS_ENDPOINT"].format(instance_id))
except:
pass
@manager.command @manager.command
def admin(localpart, domain_name, password): def admin(localpart, domain_name, password):

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
python manage.py advertise
python manage.py db upgrade python manage.py db upgrade
gunicorn -w 4 -b 0.0.0.0:80 --access-logfile - --error-logfile - --preload mailu:app gunicorn -w 4 -b 0.0.0.0:80 --access-logfile - --error-logfile - --preload mailu:app

Loading…
Cancel
Save