librelist archives

« back to archive

Shotgun?

Shotgun?

From:
Charles Roper
Date:
2011-03-17 @ 22:58
Hi Friends,

I'm a Nesta and Sinatra noob and was wondering what the significance
of shotgun is. We're running Windows at work and shotgun doesn't work
and never will due to lack of forking. It doesn't work with JRuby
either. I can use rackup, but I gather it doesn't do reloading or
something like that. What does that mean exactly?

I did some research and it seems that Sinatra::Reloader works
cross-platform (http://www.sinatrarb.com/faq.html#reloading), so could
Nesta possibly use that instead? Or am I being naive? Could anyone
give me a clue as to how to use it with Nesta? Can I simply add it to
config.ru, like this?

  require 'rubygems'
  require 'sinatra'
  require 'sinatra/reloader' if development?
  require 'bundler/setup'

  Bundler.require(:default)

  require 'nesta/app'

  Nesta::App.root = ::File.expand_path('.', ::File.dirname(__FILE__))
  run Nesta::App

Many thanks in advance for the help!

Cheers,
Charles

Re: [nesta] Shotgun?

From:
Graham Ashton
Date:
2011-03-18 @ 16:47
On 17 Mar 2011, at 22:58, Charles Roper wrote:

> I'm a Nesta and Sinatra noob and was wondering what the significance
> of shotgun is. I can use rackup, but I gather it doesn't do reloading or
> something like that. What does that mean exactly?

It's for reloading files that you change while developing your site. Edits
made since you started the web server are then visible when you refresh 
the page in your browser.

> I did some research and it seems that Sinatra::Reloader works
> cross-platform (http://www.sinatrarb.com/faq.html#reloading), so could
> Nesta possibly use that instead?

I don't see why not. I've never needed to try it, and shotgun got there 
first, which is why shotgun is documented as the approach to take.

> Can I simply add it to config.ru, like this?
> 
>  require 'rubygems'
>  require 'sinatra'
>  require 'sinatra/reloader' if development?
>  require 'bundler/setup'

You might run into issues with bundler if you do it that way; it'll 
complain because the sinatra-reloader gem isn't in the bundle.

I'd add it to the Gemfile in the development group, like this:

group :development do
  gem 'sinatra-reloader'
end

It'll then required by bundler when it gets to the Bundler.require 
statement in config.ru.

Could you let me know how you get on? If it does the trick I may see how 
well it works on Unix platforms and maybe switch Nesta over...

Cheers,
Graham

Re: [nesta] Shotgun?

From:
Charles Roper
Date:
2011-03-18 @ 17:10
Hi Graham, thanks for the answer.

On 18 March 2011 16:47, Graham Ashton <graham@effectif.com> wrote:

> It's for reloading files that you change while developing your site. 
Edits made since you started the web server are then visible when you 
refresh the page in your browser.

I thought so. The reason I asked really is because if I use plain old
rackup, when I make a change to one of the mdown files then refresh, I
see the change. Is that right? Should I not be able to see changes
when I change files?

> I'd add it to the Gemfile in the development group, like this:
>
> group :development do
>  gem 'sinatra-reloader'
> end
>
> It'll then required by bundler when it gets to the Bundler.require 
statement in config.ru.
>
> Could you let me know how you get on? If it does the trick I may see how
well it works on Unix platforms and maybe switch Nesta over...

I did that and it didn't *not* work. But then as I say, if I don't
have that in the Gemfile, I still see changes. The refreshes are quite
slow either way, though. But perhaps that's just because Ruby's
Windows I/O is slow.

Charles

Re: [nesta] Shotgun?

From:
Graham Ashton
Date:
2011-03-18 @ 17:23
On 18 Mar 2011, at 17:10, Charles Roper wrote:

> I thought so. The reason I asked really is because if I use plain old
> rackup, when I make a change to one of the mdown files then refresh, I
> see the change. Is that right? Should I not be able to see changes
> when I change files?

shotgun and sinatra-reloader are for forcing Ruby files that you might 
edit to get reloaded (this will probably include haml/sass templates, but 
I've not tried it recently).

Your .mdown files are read by Nesta itself, and it doesn't cache them in 
memory. So if you're not editing Ruby code or templates you won't need the
reloader.

Re: [nesta] Shotgun?

From:
Mika Tuupola
Date:
2011-03-18 @ 17:28
On Mar 18, 2011, at 7:23 PM, Graham Ashton wrote:

>> I thought so. The reason I asked really is because if I use plain old
>> rackup, when I make a change to one of the mdown files then refresh, I
>> see the change. Is that right? Should I not be able to see changes
>> when I change files?
> 
> shotgun and sinatra-reloader are for forcing Ruby files that you might 
edit to get reloaded (this will probably include haml/sass templates, but 
I've not tried it recently).

Shotgun reloads haml files too. Not sure about sass.

-- 
Mika Tuupola
http://www.appelsiini.net/

Re: [nesta] Shotgun?

From:
Charles Roper
Date:
2011-03-18 @ 17:54
On 18 March 2011 17:28, Mika Tuupola <tuupola@appelsiini.net> wrote:
> Shotgun reloads haml files too. Not sure about sass.

I've just tried editing the using-haml.haml page supplied with the
demo site and that updates without a reloader. What should I try to
definitively test whether the reloader is working or not?

Cheers,
Charles