Mercurial > piecrust2
annotate foodtruck/main.py @ 599:d7baac1d01e6
admin: Set the `DEBUG` flag before the app runs so we can read it during setup.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 24 Jan 2016 10:40:55 -0800 |
parents | b884bef3e611 |
children | c6bc0ef03f82 |
rev | line source |
---|---|
587
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 import logging |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 logger = logging.getLogger(__name__) |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 |
588
b884bef3e611
admin: New `admin` command to manage FoodTruck-related things.
Ludovic Chabant <ludovic@chabant.com>
parents:
587
diff
changeset
|
7 def run_foodtruck(debug=False): |
599
d7baac1d01e6
admin: Set the `DEBUG` flag before the app runs so we can read it during setup.
Ludovic Chabant <ludovic@chabant.com>
parents:
588
diff
changeset
|
8 if debug: |
d7baac1d01e6
admin: Set the `DEBUG` flag before the app runs so we can read it during setup.
Ludovic Chabant <ludovic@chabant.com>
parents:
588
diff
changeset
|
9 import foodtruck.settings |
d7baac1d01e6
admin: Set the `DEBUG` flag before the app runs so we can read it during setup.
Ludovic Chabant <ludovic@chabant.com>
parents:
588
diff
changeset
|
10 foodtruck.settings.DEBUG = debug |
d7baac1d01e6
admin: Set the `DEBUG` flag before the app runs so we can read it during setup.
Ludovic Chabant <ludovic@chabant.com>
parents:
588
diff
changeset
|
11 |
588
b884bef3e611
admin: New `admin` command to manage FoodTruck-related things.
Ludovic Chabant <ludovic@chabant.com>
parents:
587
diff
changeset
|
12 from .web import app |
587
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 try: |
588
b884bef3e611
admin: New `admin` command to manage FoodTruck-related things.
Ludovic Chabant <ludovic@chabant.com>
parents:
587
diff
changeset
|
14 app.run(debug=debug, threaded=True) |
587
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 except SystemExit: |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 # This is needed for Werkzeug's code reloader to be able to correctly |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 # shutdown the child process in order to restart it (otherwise, SSE |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 # generators will keep it alive). |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 from .views import baking |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 logger.debug("Shutting down SSE generators from main...") |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 baking.server_shutdown = True |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 raise |
d4a01a023998
admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 |