The dev.py script will now also start coffee in watch mode to automatically compile coffee files during development

This commit is contained in:
Fotis Gimian
2015-05-10 17:17:19 +10:00
parent 002006b177
commit 97e0fb0015
2 changed files with 19 additions and 1 deletions

19
dev.py
View File

@@ -1,6 +1,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from __future__ import absolute_import from __future__ import absolute_import
import os import os
import subprocess
if 'PUPPETBOARD_SETTINGS' not in os.environ: if 'PUPPETBOARD_SETTINGS' not in os.environ:
os.environ['PUPPETBOARD_SETTINGS'] = os.path.join( os.environ['PUPPETBOARD_SETTINGS'] = os.path.join(
@@ -8,8 +9,24 @@ if 'PUPPETBOARD_SETTINGS' not in os.environ:
) )
from puppetboard.app import app from puppetboard.app import app
from puppetboard.default_settings import DEV_LISTEN_HOST, DEV_LISTEN_PORT
if __name__ == '__main__': if __name__ == '__main__':
# Start CoffeeScript to automatically compile our coffee source.
# We must be careful to only start this in the parent process as
# WERKZEUG will create a secondary process when using the reloader.
if os.environ.get('WERKZEUG_RUN_MAIN') is None:
try:
subprocess.Popen([
app.config['DEV_COFFEE_LOCATION'], '-w', '-c',
'-o', 'puppetboard/static/js',
'puppetboard/static/coffeescript'
])
except OSError:
app.logger.error(
'The coffee executable was not found, disabling automatic '
'CoffeeScript compilation'
)
# Start the Flask development server
app.debug = True app.debug = True
app.run(app.config['DEV_LISTEN_HOST'], app.config['DEV_LISTEN_PORT']) app.run(app.config['DEV_LISTEN_HOST'], app.config['DEV_LISTEN_PORT'])

View File

@@ -6,6 +6,7 @@ PUPPETDB_CERT = None
PUPPETDB_TIMEOUT = 20 PUPPETDB_TIMEOUT = 20
DEV_LISTEN_HOST = '127.0.0.1' DEV_LISTEN_HOST = '127.0.0.1'
DEV_LISTEN_PORT = 5000 DEV_LISTEN_PORT = 5000
DEV_COFFEE_LOCATION = 'coffee'
UNRESPONSIVE_HOURS = 2 UNRESPONSIVE_HOURS = 2
ENABLE_QUERY = True ENABLE_QUERY = True
LOCALISE_TIMESTAMP = True LOCALISE_TIMESTAMP = True