Optimise for --preload in production
This commit is contained in:
parent
76806d3a62
commit
b9a7cf8a6f
@ -4,7 +4,7 @@ After=network.target
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/opt/virtual-metro
|
||||
ExecStart=/usr/bin/gunicorn -w 4 -b 127.0.0.1:8111 virtual_metro:app
|
||||
ExecStart=/usr/bin/gunicorn -w 4 -b 127.0.0.1:8111 --preload virtual_metro:app
|
||||
User=vmetro
|
||||
Group=vmetro
|
||||
|
||||
|
@ -138,8 +138,7 @@ def latest():
|
||||
# Cache list of stations
|
||||
stns = None
|
||||
|
||||
@app.route('/stations')
|
||||
def stations():
|
||||
def get_station_list():
|
||||
global stns
|
||||
if not stns:
|
||||
stn_list = {}
|
||||
@ -153,4 +152,10 @@ def stations():
|
||||
stns = [(k, v) for k, v in stn_list.items()]
|
||||
stns.sort(key=lambda x: x[1])
|
||||
|
||||
if not app.debug:
|
||||
get_station_list()
|
||||
|
||||
@app.route('/stations')
|
||||
def stations():
|
||||
get_station_list()
|
||||
return flask.render_template('stations.html', stations=stns)
|
||||
|
Loading…
Reference in New Issue
Block a user