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