Skip to content

Commit

Permalink
Fix #105: Updated Sanic app to use multiple workers.
Browse files Browse the repository at this point in the history
  • Loading branch information
George Su committed Jan 15, 2020
1 parent 4cf2f4c commit 6a2e5a3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion server/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from services.reporting import reports
from configparser import ConfigParser
from json import loads
from threading import Timer
from multiprocessing import cpu_count


app = Sanic(__name__)
Expand Down Expand Up @@ -105,7 +107,16 @@ async def biggestOffender(request):
return await response.file(fileOutput)


def hello_world():
print("Hello world.")

@app.route('/test_timer')
async def test_timer(request):
Timer(20.0, hello_world)
return json("Done")


if __name__ == '__main__':
configure_app()
app.run(host=app.config['Settings']['Server']['HOST'], port=app.config['Settings']['Server']['PORT'], debug=app.config['Settings']['Server']['DEBUG'])
app.run(host=app.config['Settings']['Server']['HOST'], port=int(app.config['Settings']['Server']['PORT']),
workers=cpu_count()//2, debug=app.config['Settings']['Server']['DEBUG'])

0 comments on commit 6a2e5a3

Please sign in to comment.