Commit 2e480f64 by Calen Pennington

Switch to standard coffee watcher

Using `ulimit -n` to set the limit much higher than the default of 256
in Darwin seems to avoid the `EMFILE` error that was plaguing our Mac
developers.
parent d99ad53a
...@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes, ...@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected. the top. Include a label indicating the component affected.
Common: Use coffee directly when watching for coffeescript file changes.
Common: Make rake provide better error messages if packages are missing. Common: Make rake provide better error messages if packages are missing.
Common: Repairs development documentation generation by sphinx. Common: Repairs development documentation generation by sphinx.
......
...@@ -63,6 +63,25 @@ To get a full list of available rake tasks, use: ...@@ -63,6 +63,25 @@ To get a full list of available rake tasks, use:
rake -T rake -T
### Troubleshooting
#### Reference Error: XModule is not defined (javascript)
This means that the javascript defining an xmodule hasn't loaded correctly. There are a number
of different things that could be causing this:
1. See `Error: watch EMFILE`
#### Error: watch EMFILE (coffee)
When running a development server, we also start a watcher process alongside to recompile coffeescript
and sass as changes are made. On Mac OSX systems, the coffee watcher process takes more file handles
than are allowed by default. This will result in `EMFILE` errors when coffeescript is running, and
will prevent javascript from compiling, leading to the error 'XModule is not defined'
To work around this issue, we use `Process::setrlimit` to set the number of allowed open files.
Coffee watches both directories and files, so you will need to set this fairly high (anecdotally,
8000 seems to do the trick on OSX 10.7.5, 10.8.3, and 10.8.4)
## Running Tests ## Running Tests
See `testing.md` for instructions on running the test suite. See `testing.md` for instructions on running the test suite.
......
...@@ -6,6 +6,8 @@ if USE_CUSTOM_THEME ...@@ -6,6 +6,8 @@ if USE_CUSTOM_THEME
THEME_SASS = File.join(THEME_ROOT, "static", "sass") THEME_SASS = File.join(THEME_ROOT, "static", "sass")
end end
MINIMAL_DARWIN_NOFILE_LIMIT = 8000
def xmodule_cmd(watch=false, debug=false) def xmodule_cmd(watch=false, debug=false)
xmodule_cmd = 'xmodule_assets common/static/xmodule' xmodule_cmd = 'xmodule_assets common/static/xmodule'
if watch if watch
...@@ -21,24 +23,14 @@ def xmodule_cmd(watch=false, debug=false) ...@@ -21,24 +23,14 @@ def xmodule_cmd(watch=false, debug=false)
end end
def coffee_cmd(watch=false, debug=false) def coffee_cmd(watch=false, debug=false)
if watch if watch && Launchy::Application.new.host_os_family.darwin?
# On OSx, coffee fails with EMFILE when available_files = Process::getrlimit(:NOFILE)[0]
# trying to watch all of our coffee files at the same if available_files < MINIMAL_DARWIN_NOFILE_LIMIT
# time. Process.setrlimit(:NOFILE, MINIMAL_DARWIN_NOFILE_LIMIT)
#
# Ref: https://github.com/joyent/node/issues/2479 end
#
# So, instead, we use watchmedo, which works around the problem
"watchmedo shell-command " +
"--command 'node_modules/.bin/coffee -c ${watch_src_path}' " +
"--recursive " +
"--patterns '*.coffee' " +
"--ignore-directories " +
"--wait " +
"."
else
'node_modules/.bin/coffee --compile .'
end end
"node_modules/.bin/coffee --compile #{watch ? '--watch' : ''} ."
end end
def sass_cmd(watch=false, debug=false) def sass_cmd(watch=false, debug=false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment