Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove watchify code from cli, it belongs in runserver (which works!) #5314

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/installguide/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Bug fixes
* Use current year in footer text :url-issue:`5055`
* New setting ``HIDE_CONTENT_RATING`` for hiding content rating box :url-issue:`5104`


Known issues
^^^^^^^^^^^^

Expand Down Expand Up @@ -82,6 +83,8 @@ that the following management commands have been removed:
* ``kalite manage compileymltojson``
* ``kalite manage restorebackup``
* ``kalite manage kalitebackup``
* Remove ``--watch`` option from ``bin/kalite start`` because ``bin/kalite manage runserver`` does the job. :url-issue:`5314`


0.16.9
------
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