Mercurial > piecrust2
annotate foodtruck/main.py @ 619:200c7063affa
admin: Change the default admin server port to 8090, add `--port` option.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 06 Feb 2016 21:47:24 -0800 |
parents | c6bc0ef03f82 |
children | 3885421c29a3 |
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 |
619
200c7063affa
admin: Change the default admin server port to 8090, add `--port` option.
Ludovic Chabant <ludovic@chabant.com>
parents:
602
diff
changeset
|
7 def run_foodtruck(host=None, port=None, 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: |
619
200c7063affa
admin: Change the default admin server port to 8090, add `--port` option.
Ludovic Chabant <ludovic@chabant.com>
parents:
602
diff
changeset
|
14 app.run(host=host, port=port, 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). |
602
c6bc0ef03f82
admin: Better UI for publishing websites.
Ludovic Chabant <ludovic@chabant.com>
parents:
599
diff
changeset
|
19 from . import pubutil |
587
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...") |
602
c6bc0ef03f82
admin: Better UI for publishing websites.
Ludovic Chabant <ludovic@chabant.com>
parents:
599
diff
changeset
|
21 pubutil.server_shutdown = True |
587
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 |