jstorimer / spin

Spin speeds up your Rails testing workflow by preloading your Rails environment.

Home Page:http://jstorimer.github.com/spin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stop Spin Command

vizjerai opened this issue · comments

I've made changes for the https://github.com/vizjerai/guard-spin gem but there isn't a good way to stop Spin.

Currently the gem stops the UnixSocket directly and Spin pukes when it tries to run the loop and the socket is no longer there.

I would rather have a simple command to stop Spin instead of copying internal methods that could change in the future.

How about if the spin server cleans up after itself when exiting? Would that serve the purpose? Probably a good idea anyways.

Something like:

at_exit do
  File.delete(socket_file)
end

That would be fine. But there isn't a way to tell spin to exit right now. Unless i'm missing something.

Here is a trace after guard-spin exits and the UNIXSocket is closed and the socket_file deleted.

/.rvm/gems/ruby-1.9.3-p0/gems/spin-0.1.4/bin/spin:68:in `block in serve': undefined method `chomp' for nil:NilClass (NoMethodError)
        from /.rvm/gems/ruby-1.9.3-p0/gems/spin-0.1.4/bin/spin:63:in `loop'
        from /.rvm/gems/ruby-1.9.3-p0/gems/spin-0.1.4/bin/spin:63:in `serve'
        from /.rvm/gems/ruby-1.9.3-p0/gems/spin-0.1.4/bin/spin:147:in `<top (required)>'
        from /.rvm/gems/ruby-1.9.3-p0/bin/spin:19:in `load'
        from /.rvm/gems/ruby-1.9.3-p0/bin/spin:19:in `<main>'

I'm fine with changing the guard script if there is a better or cleaner way.

ah I see what you're trying to do. You'll need to fork + exec spin server so you can kill it later with a signal. It's almost there.

I can contribute a patch later tonight that should fix this.