Skip to content

Commit

Permalink
Remove watchify code from cli, it belongs in runserver (which works!)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Bach committed Oct 3, 2016
1 parent 9254958 commit df484fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 50 deletions.
1 change: 1 addition & 0 deletions docs/installguide/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^
Expand Down
57 changes: 7 additions & 50 deletions kalite/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit df484fd

Please sign in to comment.