From df484fdec81077664b89a3b9e64b575391c7824f Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Mon, 3 Oct 2016 21:37:54 +0200 Subject: [PATCH] Remove watchify code from cli, it belongs in runserver (which works!) --- docs/installguide/release_notes.rst | 1 + kalite/cli.py | 57 ++++------------------------- 2 files changed, 8 insertions(+), 50 deletions(-) diff --git a/docs/installguide/release_notes.rst b/docs/installguide/release_notes.rst index bd85715863..2dbeb1f1a5 100644 --- a/docs/installguide/release_notes.rst +++ b/docs/installguide/release_notes.rst @@ -20,6 +20,7 @@ Bug fixes * Activating simplified login results in blank login modal :url-issue:`5255` * ``favicon.ico`` missing in distributed set of files, little KA green leaf now appears in browser window decorations and shortcuts :url-issue:`5306` * Use current year in footer text :url-issue:`5055` + * Remove ``--watch`` option from ``bin/kalite start`` because ``bin/kalite manage runserver`` does the job. :url-issue:`5314` Known issues ^^^^^^^^^^^^ diff --git a/kalite/cli.py b/kalite/cli.py index cccc47a594..c1e2ea3ea0 100644 --- a/kalite/cli.py +++ b/kalite/cli.py @@ -6,7 +6,7 @@ www.learningequality.org Usage: - kalite start [--foreground --watch] [options] [DJANGO_OPTIONS ...] + kalite start [--foreground] [options] [DJANGO_OPTIONS ...] kalite stop [options] [DJANGO_OPTIONS ...] kalite restart [options] [DJANGO_OPTIONS ...] kalite status [options] @@ -46,8 +46,6 @@ kalite start --foreground Run kalite in the foreground and do not go to daemon mode. - kalite start --watch Set cherrypy to watch for changes to Django code and start - the Watchify process to recompile Javascript dynamically. Planned features: Universal --verbose option and --debug option. Shows INFO level and DEBUG @@ -423,42 +421,7 @@ def manage(command, args=None, as_thread=False): return thread -# Watchify running code modified from: -# https://github.com/beaugunderson/django-gulp/blob/master/django_gulp/management/commands/runserver.py - -def start_watchify(): - sys.stdout.write('Starting watchify') - - watchify_process = subprocess.Popen( - args='node build.js --debug --watch --staticfiles', - shell=True, - stdin=subprocess.PIPE, - stdout=sys.stdout, - stderr=sys.stderr) - - if watchify_process.poll() is not None: - raise RuntimeError('watchify failed to start') - - print('Started watchify process on pid {0}'.format( - watchify_process.pid)) - - with open(NODE_PID_FILE, 'w') as f: - f.write("%d" % watchify_process.pid) - - atexit.register(kill_watchify_process) - -def kill_watchify_process(): - pid, __ = read_pid_file(NODE_PID_FILE) - # PID file exists, but process is dead - if not pid_exists(pid): - print('watchify process not running') - else: - kill_pid(pid) - os.unlink(NODE_PID_FILE) - sys.stdout.write('watchify process killed') - - -def start(debug=False, watch=False, daemonize=True, args=[], skip_job_scheduler=False, port=None): +def start(debug=False, daemonize=True, args=[], skip_job_scheduler=False, port=None): """ Start the kalite server as a daemon @@ -519,11 +482,6 @@ def start(debug=False, watch=False, daemonize=True, args=[], skip_job_scheduler= manage('initialize_kalite') - if watch: - watchify_thread = Thread(target=start_watchify) - watchify_thread.daemon = True - watchify_thread.start() - # Remove the startup lock at this point if STARTUP_LOCK: os.unlink(STARTUP_LOCK) @@ -571,11 +529,11 @@ def start(debug=False, watch=False, daemonize=True, args=[], skip_job_scheduler= }) DjangoAppPlugin(cherrypy.engine).subscribe() - if not watch: - # cherrypyserver automatically reloads if any modules change - # Switch-off that functionality here to save cpu cycles - # http://docs.cherrypy.org/stable/appendix/faq.html - cherrypy.engine.autoreload.unsubscribe() + + # cherrypyserver automatically reloads if any modules change + # Switch-off that functionality here to save cpu cycles + # http://docs.cherrypy.org/stable/appendix/faq.html + cherrypy.engine.autoreload.unsubscribe() try: cherrypy.quickstart() @@ -924,7 +882,6 @@ def main(): if arguments['start']: start( debug=arguments['--debug'], - watch=arguments['--watch'], skip_job_scheduler=arguments['--skip-job-scheduler'], args=arguments['DJANGO_OPTIONS'], daemonize=not arguments['--foreground'],