-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
46 lines (34 loc) · 889 Bytes
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from aiohttp import web
from manager import Manager
from app.app import app
from writer.app import app as writer_app
manager = Manager()
@manager.command
def runserver():
web.run_app(app, host='0.0.0.0', port=8080)
@manager.command
def runwriter():
web.run_app(writer_app, host='0.0.0.0', port=8070)
@manager.command
def init_db():
import peewee
from app.app import db
from app.models import (
Project,
Click,
Event,
Rate,
ProjectRate,
Statistics,
)
db.set_allow_sync(True)
print('Creating tables')
for model in (Project, Click, Event, Rate, ProjectRate, Statistics):
try:
model.create_table()
except peewee.ProgrammingError:
db.close()
else:
print('Create %s' % model.__name__.lower())
if __name__ == '__main__':
manager.main()