librelist archives

« back to archive

External access to staging site?

External access to staging site?

From:
Isaac Rabinovitch
Date:
2012-12-06 @ 23:12
I do all my ruby experimentation on a CentOS VM on Parallels on Windows. 
I have an Apache server and minimal Sinatra applications running on the 
VM. These I can access from a Windows browser via the VM IP address, no 
problem.

I just installed and started Nesta on the VM. I know it's working, 
because I can access it via localhost:9393. But access through the IP 
address gives a refused connection. That's a pain, because it's easier 
to test my site from Windows than from the VM.

Re: [nesta] External access to staging site?

From:
Graham Ashton
Date:
2012-12-06 @ 23:20
On 6 Dec 2012, at 23:12, Isaac Rabinovitch <isaac@picknit.com> wrote:

> I just installed and started Nesta on the VM. I know it's working, 
> because I can access it via localhost:9393. But access through the IP 
> address gives a refused connection. That's a pain, because it's easier 
> to test my site from Windows than from the VM.

Shotgun doesn't listen on all interfaces by default. Try this:

$ shotgun config.ru -o 0.0.0.0

If you're running it differently, it'll be the same problem, but with 
whichever local web server you're using.

--
Graham Ashton
Founder, The Agile Planner
http://www.theagileplanner.com | @agileplanner | @grahamashton



Re: [nesta] External access to staging site?

From:
Isaac Rabinovitch
Date:
2012-12-06 @ 23:31
Yup. Thanks!

On 12/6/2012 3:20 PM, Graham Ashton wrote:
> On 6 Dec 2012, at 23:12, Isaac Rabinovitch <isaac@picknit.com> wrote:
>
>> I just installed and started Nesta on the VM. I know it's working,
>> because I can access it via localhost:9393. But access through the IP
>> address gives a refused connection. That's a pain, because it's easier
>> to test my site from Windows than from the VM.
> Shotgun doesn't listen on all interfaces by default. Try this:
>
> $ shotgun config.ru -o 0.0.0.0
>
> If you're running it differently, it'll be the same problem, but with 
whichever local web server you're using.
>
> --
> Graham Ashton
> Founder, The Agile Planner
> http://www.theagileplanner.com | @agileplanner | @grahamashton
>
>
>
>

Re: [nesta] External access to staging site?

From:
Brian Gonzalez
Date:
2012-12-06 @ 23:36
Shotgun hasn't been touched in over 2 years (
https://github.com/rtomayko/shotgun). I would recommend using thin:

thin start -R config.ru -p 7000

Thin listens on all interfaces by default.


On Thu, Dec 6, 2012 at 3:31 PM, Isaac Rabinovitch <isaac@picknit.com> wrote:

> Yup. Thanks!
>
> On 12/6/2012 3:20 PM, Graham Ashton wrote:
> > On 6 Dec 2012, at 23:12, Isaac Rabinovitch <isaac@picknit.com> wrote:
> >
> >> I just installed and started Nesta on the VM. I know it's working,
> >> because I can access it via localhost:9393. But access through the IP
> >> address gives a refused connection. That's a pain, because it's easier
> >> to test my site from Windows than from the VM.
> > Shotgun doesn't listen on all interfaces by default. Try this:
> >
> > $ shotgun config.ru -o 0.0.0.0
> >
> > If you're running it differently, it'll be the same problem, but with
> whichever local web server you're using.
> >
> > --
> > Graham Ashton
> > Founder, The Agile Planner
> > http://www.theagileplanner.com | @agileplanner | @grahamashton
> >
> >
> >
> >
>
>

Re: [nesta] External access to staging site?

From:
Isaac Rabinovitch
Date:
2012-12-06 @ 23:38
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Well, being a newbie, I'm working from the intro on
    <a class="moz-txt-link-freetext" 
href="http://nestacms.com/">http://nestacms.com/</a>. Perhaps this needs 
to be updated?<br>
    <br>
    <div class="moz-cite-prefix">On 12/6/2012 3:36 PM, Brian Gonzalez
      wrote:<br>
    </div>
    <blockquote
cite="mid:CALaWykhUt1VwF0tLGVPjRxwsZfpSjnHPHpOQNNKJajv0UBt0pw@mail.gmail.com"
      type="cite">Shotgun hasn't been touched in over 2 years (<a
        moz-do-not-send="true"
        
href="https://github.com/rtomayko/shotgun">https://github.com/rtomayko/shotgun</a>).
      I would recommend using thin:
      <div><br>
      </div>
      <div>thin start -R <a moz-do-not-send="true"
          href="http://config.ru">config.ru</a> -p 7000<br>
      </div>
      <div><br>
      </div>
      <div>Thin listens on all interfaces by default.</div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Thu, Dec 6, 2012 at 3:31 PM, Isaac
          Rabinovitch <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:isaac@picknit.com" 
target="_blank">isaac@picknit.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Yup.
            Thanks!<br>
            <br>
            On 12/6/2012 3:20 PM, Graham Ashton wrote:<br>
            > On 6 Dec 2012, at 23:12, Isaac Rabinovitch <<a
              moz-do-not-send="true" 
href="mailto:isaac@picknit.com">isaac@picknit.com</a>>
            wrote:<br>
            ><br>
            >> I just installed and started Nesta on the VM. I
            know it's working,<br>
            >> because I can access it via localhost:9393. But
            access through the IP<br>
            >> address gives a refused connection. That's a pain,
            because it's easier<br>
            >> to test my site from Windows than from the VM.<br>
            > Shotgun doesn't listen on all interfaces by default.
            Try this:<br>
            ><br>
            > $ shotgun <a moz-do-not-send="true"
              href="http://config.ru" target="_blank">config.ru</a> -o
            0.0.0.0<br>
            ><br>
            > If you're running it differently, it'll be the same
            problem, but with whichever local web server you're using.<br>
            <span class="HOEnZb"><font color="#888888">><br>
                > --<br>
                > Graham Ashton<br>
                > Founder, The Agile Planner<br>
                > <a moz-do-not-send="true"
                  href="http://www.theagileplanner.com" 
target="_blank">http://www.theagileplanner.com</a>
                | @agileplanner | @grahamashton<br>
                ><br>
                ><br>
                ><br>
                ><br>
                <br>
              </font></span></blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>

Re: [nesta] External access to staging site?

From:
Graham Ashton
Date:
2012-12-06 @ 23:45
On 6 Dec 2012, at 23:38, Isaac Rabinovitch <isaac@picknit.com> wrote:

> Well, being a newbie, I'm working from the intro on
> http://nestacms.com/. Perhaps this needs to be updated?

Don't worry too much - I still use shotgun all the time.

I'll try running something else in development tomorrow though and update 
the docs if I think one of these other approaches makes more sense as the 
default suggestion.

--
Graham Ashton
Founder, The Agile Planner
http://www.theagileplanner.com | @agileplanner | @grahamashton



Re: [nesta] External access to staging site?

From:
Graham Ashton
Date:
2012-12-07 @ 09:00
On 6 Dec 2012, at 23:45, Graham Ashton <graham@effectif.com> wrote:

> I'll try running something else in development tomorrow though and 
update the docs if I think one of these other approaches makes more sense 
as the default suggestion.

I've done a bit of research. tl;dr - shotgun is going to remain the 
documented approach, but it's been an interesting couple of hours.

I've compared the following options for reloading code in a Nesta site 
that's running on your laptop/desktop:

- shotgun
- Rack::Reloader
- Sinatra::Reloader (part of sinatra-contrib)
- rerun

Let me know if I missed a good candidate and I'll re-review it.

They adopt quite different approaches.

shotgun forks a new process for every request. Sounds costly, but neatly 
side steps all the issues that come with trying to write code to reload 
things cleanly. Forking allows it to start a new process fairly 
efficiently. It doesn't serve your files as fast as some other approaches,
but it will work every time.

Rack::Reloader is nice and simple, but unsuitable for reloading Sinatra 
apps. There's code in Sinatra that it can't cope with properly.

Sinatra::Reloader is a bit smarter than Rack::Reloader, but the semantics 
of what it can/can't or will/won't reload will be non-obvious to people 
who aren't Ruby developers. If I was building a Sinatra app that wasn't 
for public consumption (or would only be used by Ruby developers), I'd 
definitely use it. Nesta is used by plenty of people who don't do Ruby, so
we need to keep things simple.

rerun gives you the benefit of being able to use a very snappy web server 
(such as thin) in development, but when it restarts thin it does a cold 
restart. This means thin has to temporarily stops listening for requests. 
Though thin serves pages faster, the period of downtime while thin 
restarts is too slow for me. I either reload the page faster manually, or 
I find that guard-livereload tells my browser to reload the page before 
thin is ready to serve a new request. The results are worse than shotgun's
slowness. See [1] if you've never experimented with livereload - it's 
fantastic.

So I think we should stick with shotgun as the main documented approach. 
Should somebody fancy contributing an article on faster alternatives for 
the more Ruby oriented, I'd welcome it.

For an in depth breakdown of most of the above, see Konstantin Hasse's 
write up of what he did during his Google summer of code project to 
rewrite the code reloader (ActiveSupport::Dependencies) in Rails. [2]

If you read Konstantin's article all the way through you'll come across a 
link to Magical Reloading Sparkles [3]. Technically it's a great solution,
with all the benefits of shotgun and rerun+thin combined (it'll serve 
pages *very* fast, only restart servers on demand, and won't drop 
connections while it's doing it). Using unicorn like this would require 
some development to wrap it up for use with Nesta (e.g. in a `nesta start`
command), and it's not a high enough priority for me right now. It's 
tempting though...

On the issue of shotgun not having been touched for two years, I reckon 
it's not always a bad sign. Some software just works, and the lack of 
churn in the code is a good thing. If we find at some point in the future 
that it needs some love and there are no better options available, I'll 
either fix it or do something with Unicorn and the "sparkles" solution.

[1] http://nestacms.com/docs/recipes/automatically-reload-pages-as-you-write
[2] http://rkh.im/code-reloading
[3] http://namelessjon.posterous.com/magical-reloading-sparkles

--
Graham Ashton
Founder, The Agile Planner
http://www.theagileplanner.com | @agileplanner | @grahamashton



Re: [nesta] External access to staging site?

From:
Mika Tuupola
Date:
2012-12-07 @ 09:20
On Dec 7, 2012, at 11:00 AM, Graham Ashton wrote:

> I've compared the following options for reloading code in a Nesta site 
that's running on your laptop/desktop:
> 
> - shotgun
> - Rack::Reloader
> - Sinatra::Reloader (part of sinatra-contrib)
> - rerun


If you use Passenger on your dev laptop you can also do  

$ touch tmp/always_restart.txt

and when your done just remove the file. Personally I use both Passenger 
and Shotgun depending on the project.

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

Re: [nesta] External access to staging site?

From:
Isaac Rabinovitch
Date:
2012-12-06 @ 23:48
I suppose the typical Nesta user would access the staging site from the 
same machine they're running it on....
On 12/6/2012 3:45 PM, Graham Ashton wrote:
> On 6 Dec 2012, at 23:38, Isaac Rabinovitch <isaac@picknit.com> wrote:
>
>> Well, being a newbie, I'm working from the intro on
>> http://nestacms.com/. Perhaps this needs to be updated?
> Don't worry too much - I still use shotgun all the time.
>
> I'll try running something else in development tomorrow though and 
update the docs if I think one of these other approaches makes more sense 
as the default suggestion.
>
> --
> Graham Ashton
> Founder, The Agile Planner
> http://www.theagileplanner.com | @agileplanner | @grahamashton
>
>
>
>