烧瓶APScheduler生产

时间:2016-12-11 14:36:05

标签: python nginx flask uwsgi apscheduler

我是第一次在python-flask中创建API。我正在关注本教程Link。当我使用nohup python时,一切正常,Flask-APScheduler也正常。当我通过教程配置uWSGI和Nginx时,我的API正在运行,但APScheduler不起作用,我不知道为什么。谢谢你的回复。

wsgi.py
zlty.ini
config.py
app
    __init__.py
    zlty.py

config.py

import os
basedir = os.path.abspath(os.path.dirname(__file__))

SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
SQLALCHEMY_TRACK_MODIFICATIONS = False
DEBUG = True
APNS_CERTIFICATE = 'prodnopass.pem'
APNS_SANDBOX = False
JOBS = [
        {
            'id': 'first',
            'func': 'app.zlty:firstRoutes',
            'trigger': 'interval',
            'seconds': 120
        }, {
            'id': 'second',
            'func': 'app.zlty:secondRoutes',
            'trigger': 'interval',
            'seconds': 300
        }, {
            'id': 'third',
            'func': 'app.zlty:thirdRoutes',
            'trigger': 'interval',
            'seconds': 1860
        }
    ]   

wsgi.py

from app import app, scheduler, zlty

if __name__ == "__main__":
    scheduler.start()
    app.run(host='0.0.0.0')

初始化的.py

from flask import Flask, request
from flask_autodoc import Autodoc
from flask_sqlalchemy import SQLAlchemy
from flask_mail import Mail
from flask_pushjack import FlaskAPNS
from flask_apscheduler import APScheduler
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
auto = Autodoc(app)
mail = Mail(app)
clientapns = FlaskAPNS()
clientapns.init_app(app)
scheduler = APScheduler()
scheduler.init_app(app)

from app import zlty, models

0 个答案:

没有答案