voltrb / volt

A Ruby web framework where your Ruby runs on both server and client
MIT License
3.22k stars 196 forks source link

Volt auto file-reloading sometimes breaks whole server until computer restart #278

Open Qqwy opened 9 years ago

Qqwy commented 9 years ago

It regularly (multiple times a day) happens to me that the Volt Server is showing this message:

[INFO] file changed, reloading server and client...

without any progress. When exiting out of the server in this state, using Ctrl+C or Ctrl+Z (^C, ^Z), I get the following error:

Exiting...
Stop Child Error: #<ArgumentError: Listen::Listener can't change state from 'backend_started' to 'stopped', only to: frontend_ready>

After this, when trying to restart the server using volt s or similar commands, I get the following error stack:

/home/qqwy/.rvm/gems/ruby-2.2.1/gems/rb-inotify-0.9.5/lib/rb-inotify/notifier.rb:58:in `initialize': Too many open files - Failed to initialize inotify: the user limit on the total number of inotify instances has been reached. (Errno::EMFILE)
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/adapter/linux.rb:31:in `new'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/adapter/linux.rb:31:in `_configure'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/adapter/base.rb:45:in `block in configure'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/adapter/base.rb:40:in `each'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/adapter/base.rb:40:in `configure'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/adapter/base.rb:63:in `start'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/backend.rb:26:in `start'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/listener.rb:67:in `block in <class:Listener>'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/fsm.rb:120:in `instance_eval'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/fsm.rb:120:in `call'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/fsm.rb:91:in `transition_with_callbacks!'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/fsm.rb:57:in `transition'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/listen-3.0.3/lib/listen/listener.rb:90:in `start'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/volt-0.9.4/lib/volt/server/forking_server.rb:242:in `start_change_listener'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/volt-0.9.4/lib/volt/server/forking_server.rb:65:in `start_child'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/volt-0.9.4/lib/volt/server/forking_server.rb:34:in `initialize'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/volt-0.9.4/lib/volt/server.rb:80:in `new'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/volt-0.9.4/lib/volt/server.rb:80:in `app'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/volt-0.9.4/lib/volt/cli.rb:79:in `server'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/volt-0.9.4/lib/volt/cli.rb:135:in `<top (required)>'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/volt-0.9.4/bin/volt:4:in `require'
from /home/qqwy/.rvm/gems/ruby-2.2.1/gems/volt-0.9.4/bin/volt:4:in `<top (required)>'
from /home/qqwy/.rvm/gems/ruby-2.2.1/bin/volt:23:in `load'
from /home/qqwy/.rvm/gems/ruby-2.2.1/bin/volt:23:in `<main>'
from /home/qqwy/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
from /home/qqwy/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'

The only way I found to resolve this problem has been to restart my computer. There might be another way to delete the floating inotify process but I have not found out how (for instance, it does not show up when I do ps aux | grep inotify on Linux).

dennym commented 9 years ago

Have you tried looking for ps aux | grep volt Appears to me sometime that there are lose volt server task running in the background.

ryanstout commented 9 years ago

@Qqwy I think this issue is in the listen gem - https://github.com/guard/listen/issues/340

jfahrer commented 9 years ago

It seams to happen when there is syntax error after a code reload. The clients tries to reconnect several times per second.

As a workaround I just kill all processes running volt (ruby).