-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathapp.py
36 lines (29 loc) · 1.1 KB
/
app.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
from os import environ
from subprocess import call
from anyaudio.helpers.database import init_databases
from anyaudio.schedulers import trending, youtube_dl_upgrade
if __name__ == '__main__':
# Create SQLite tables
init_databases()
# Start schedulers
trending_scheduler = trending.TrendingScheduler()
trending_scheduler.start()
youtube_dl_upgrade_scheduler = youtube_dl_upgrade.YoutubeDLUpgrader()
youtube_dl_upgrade_scheduler.start()
call(['bash', 'run.sh'])
# http://docs.gunicorn.org/en/stable/settings.html
cmd = 'gunicorn anyaudio:app -w 4'
# Comment following line on CentOS due to bug in eventlet
cmd += ' --worker-class eventlet'
cmd += ' --reload'
cmd += ' --log-level info'
cmd += ' -b %s:%s' % (
environ.get('OPENSHIFT_PYTHON_IP', '127.0.0.1'),
environ.get('OPENSHIFT_PYTHON_PORT', '5000')
)
cmd += ' --worker-connections 1000 -t 150' # 4 mins = 10 secs
call(cmd.split())
# app.run(
# host=environ.get('OPENSHIFT_PYTHON_IP', '127.0.0.1'),
# port=int(environ.get('OPENSHIFT_PYTHON_PORT', 5000))
# )