forked from rDrama/rDrama
Enable flask command, add cron target.
Adding an empty __init__.py, the imports-only cli.py, and setting FLASK_APP in the environment are enough to get the `flask` command to work. This will enable future changes, including database migrations. The proximate reason for the fix is to add a `flask cron` command to run scheduled tasks within the application from cron. Specifically, the lottery should be run from cron.master
parent
aaeb09fd91
commit
acb3a0b338
1
env
1
env
|
@ -1,3 +1,4 @@
|
||||||
|
export FLASK_APP="/service/files/cli:app"
|
||||||
export MASTER_KEY="blahblahblah"
|
export MASTER_KEY="blahblahblah"
|
||||||
export DOMAIN="localhost"
|
export DOMAIN="localhost"
|
||||||
export SITE_NAME="rDrama"
|
export SITE_NAME="rDrama"
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
from .__main__ import app, db_session
|
||||||
|
from flask import g
|
||||||
|
import files.helpers.cron
|
||||||
|
|
||||||
|
#from flask_migrate import Migrate
|
||||||
|
#from flask_sqlalchemy import SQLAlchemy
|
||||||
|
#import files.classes
|
||||||
|
|
||||||
|
#db = SQLAlchemy(app)
|
||||||
|
#migrate = Migrate(app, db)
|
|
@ -0,0 +1,18 @@
|
||||||
|
from files.cli import g, app, db_session
|
||||||
|
import click
|
||||||
|
import files.helpers.lottery
|
||||||
|
|
||||||
|
@app.cli.command('cron', help='Run scheduled tasks.')
|
||||||
|
@click.option('--every-5m', is_flag=True, help='Call every 5 minutes.')
|
||||||
|
@click.option('--every-1h', is_flag=True, help='Call every 1 hour.')
|
||||||
|
@click.option('--every-1d', is_flag=True, help='Call every 1 day.')
|
||||||
|
def cron(every_5m, every_1h, every_1d):
|
||||||
|
g.db = db_session()
|
||||||
|
|
||||||
|
if every_5m:
|
||||||
|
pass
|
||||||
|
if every_1h:
|
||||||
|
pass
|
||||||
|
if every_1d:
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue