Re: Sinatra 0.9.2 and Shotgun 0.3 confusion

35 views
Skip to first unread message

Ryan Tomayko

unread,
Jun 15, 2009, 3:32:42 PM6/15/09
to sina...@googlegroups.com, Satish Talim
Hi Satish, Please direct future questions to the Sinatra mailing list:

http://groups.google.com/group/sinatrarb

I've copied the list on my response.

On Sun, Jun 14, 2009 at 11:58 PM, Satish Talim<ma...@satishtalim.com> wrote:
> 15th June
> Hello Ryan,
>
> We had interacted when I interviewed you for RubyLearning.
>
> Today, I upgraded to Sinatra 0.9.2 on Windows and realised that it no longer
> supports application reloading in development mode. Someone suggested
> Shotgun. As such, I installed it, but am unable to use the same.

Source file reloading was removed in Sinatra 0.9.2. The FAQ has some
details and suggestions for alternatives:

http://www.sinatrarb.com/faq.html#reloading

> a. Is a config.ru file necessary for a local app on my PC?

Nope. You can point shotgun at a Sinatra app file directly.

> b. Do I run a Sinatra app by typing:
>
> shotgun hello.rb

Yes. See `shotgun --help` for more advanced usage.

> c. How do I access the Sinatra app in my browser?
> http://localhost:9393/

Yes. You should receive output with the port number shotgun is listening on.

> Am I missing something?

Shotgun does not work on Windows or JRuby due to lack of sane fork(2)
on those platforms. Windows users may be able to use Rack::Reloader
for source file reloading. JRuby users may be able to get their web
container to perform reloading.

Thanks,
Ryan

Alex Chaffee

unread,
Jun 16, 2009, 1:27:55 PM6/16/09
to sina...@googlegroups.com, Satish Talim
I just released "rerun" which is a reloader like Shotgun but with a
different architecture. If you try it out I'd love to hear about your
experiences. I'd especially like to know if it works on Linux or
Windows.

http://github.com/alexch/rerun

From the README:

Launches your app, then watches the filesystem. If a relevant file
changes, then it restarts your app.

Currently only *.rb files are watched, anywhere under the current
directory (.). This is pretty lame so it will change soon.

If you're on Mac OS X, it uses the built-in facilities for monitoring
the filesystem, so CPU use is very light.

If you have "growlcmd" available on the PATH, it sends notifications
to growl in addition to the console.

Why would I use this instead of Shotgun?

Shotgun does a "fork" after the web framework has loaded but before
your application is loaded. It then loads your app, processes a single
request in the child process, then exits the child process.

Rerun launches the whole app, then when it's time to restart, uses
"kill" to shut it down and starts the whole thing up again from
scratch.

So rerun takes somewhat longer than Shotgun to restart the app, but
does it much less frequently. And once it's running it behaves more
normally and consistently with your production app.

Also, Shotgun reloads the app on every request, even if it doesn't
need to. This is fine if you're loading a single file, but my web
pages all load other files (CSS, JS, media) and that adds up quickly.
The developers of shotgun are probably using caching or a front web
server so this doesn't affect them too much.

YMMV!




---
Alex Chaffee - al...@stinky.com - http://alexch.github.com
Stalk me: http://friendfeed.com/alexch | http://twitter.com/alexch |
http://alexch.tumblr.com

Adam Strzelecki

unread,
Jun 18, 2009, 9:44:10 AM6/18/09
to sina...@googlegroups.com, Satish Talim
I just don't get why release another reloader such as "shotgun" or
"rerun" if there's Rack::Reloader available for quite a while.
Seems I'd need to write my own too once everybody has one ;P

Cheers,
--
Adam

Alex Chaffee

unread,
Jun 18, 2009, 10:37:30 AM6/18/09
to sina...@googlegroups.com, Adam Strzelecki

Rack::Reloader is cool and very elegant but it wasn't working for me
for a couple of reasons:

* It only reloads .rb files that were 'require'd, not 'load'ed. That
leaves out (non-Erector) template files, and also, the way I was doing
it, sub-actions (see
http://groups.google.com/group/sinatrarb/browse_thread/thread/7329727a9296e96a#
).

* It doesn't reload configuration changes or other things that happen
during app startup.

* It does a "stat" on every file on every request which is quite
wasteful and also changes the subjective performance, so it's harder
to tell in development how your app will behave in production. Rerun
runs in a separate process, and if you're on a Mac it uses OS X's
built-in directory-watching facility so it's very low-impact.

And if you want to make a reloader of your own, please do! Let a
thousand flowers bloom... :-)

Adam Strzelecki

unread,
Jun 18, 2009, 2:20:23 PM6/18/09
to Alex Chaffee, sina...@googlegroups.com
> * It does a "stat" on every file on every request which is quite
> wasteful and also changes the subjective performance, so it's harder
> to tell in development how your app will behave in production. Rerun
> runs in a separate process, and if you're on a Mac it uses OS X's
> built-in directory-watching facility so it's very low-impact.

Not per each request, but per each while (number of seconds defined
inside Reloader).
Moreover "stat" isn't wasteful since it does NOT require any disk
access, usually last accessed inodes are cached by memory. (There's
even explaination about this in Rack docs AFAIR)

> And if you want to make a reloader of your own, please do! Let a
> thousand flowers bloom... :-)

Haha... but which one to pick if each is so pretty?

Cheers,
--
Adam

Maurizio Balestrieri

unread,
Jun 23, 2009, 1:56:38 AM6/23/09
to sinatrarb
I'm using it, and it is doing well. Keep up the good work. How do you
suggest stay updated to new developments of rerun?
> Alex Chaffee - a...@stinky.com -http://alexch.github.com
> Stalk me:http://friendfeed.com/alexch|http://twitter.com/alexch|http://alexch.tumblr.com
>
>
>
> On Mon, Jun 15, 2009 at 12:32 PM, Ryan Tomayko<r...@tomayko.com> wrote:
>
> > Hi Satish, Please direct future questions to the Sinatra mailing list:
>
> >http://groups.google.com/group/sinatrarb
>
> > I've copied the list on my response.
>

Alex Chaffee

unread,
Jun 24, 2009, 10:12:47 PM6/24/09
to sina...@googlegroups.com
Just keep looking at this list, and do an occasional "gem update." I'll probably make a blog post about it on Pivotal Blabs once I get a few more users too.

Reply all
Reply to author
Forward
0 new messages