Forum: Ruby on Rails scgi routing problem not DRY (update to SCGI and caching not

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
mortonda (Guest)
on 2005-11-16 17:38
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm attempting to set up typo using the SCGI runner.  As near as I can
tell,
here's what happens, please tell me if I'm wrong:

The instructions for scgi and rails:

(http://wiki.rubyonrails.com/rails/pages/SCGI+Rails...)

seem to indicate to set the scgi base to /scgi-bin/:

SCGIMount /scgi-bin/ 127.0.0.1:9999

and not

SCGIMount / 127.0.0.1:9999

as I would have done on first thought.  Thinking about it, I conclude
that if
the scgi engine is on / and not /scgi-bin/, then a conditional rewrite
rule
isn't needed/can't be made, and thus page caching cannot work; apache
won't
bypass running SCGI, which is how caching works.

By placing the scgi engine on /scgi-bin/, we use a conditional rewrite
to run
scgi if a cached file is not found:

RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /scgi-bin/$1 [QSA,L]

This introduces an ugly sgci-bin into our url, so the workaround is to
double up
on the routes:

map.connect ':controller/:action/:id'
map.connect 'scgi-bin/:controller/:action/:id'

which makes rails recognize the scgi-bin part of the path, and still
write
pretty urls too.  However, this is kinda repetitive when one uses a
bunch of
routes, as typo does.

So, in the end, I think I can get typo running in one of two ways:

1: mount scgi on /, leave routing alone, don't use a rewriting rule.
Everything
works, except no page caching can be done, because there's no way to
avoid scgi.

2: mount scgi on /scgi-bin and all taht, and add all the route commands
to
rewrite the scgi-bin out of the request.  Now routing will work.

In the end, we have a problem that in order to use SCGI, we either
violate DRY
or we can't cache pages.

- --
David M.
Maia Mailguard                        - http://www.maiamailguard.com
Morton Software Design and Consulting - http://www.dgrmm.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDe1HASIxC85HZHLMRAqnMAJ9VYHnuPhp3/j1oG/1C9pYPTzHajQCdEGhI
3YmE/KhsB+cFLdQ6CaY2UiI=
=Q1DE
-----END PGP SIGNATURE-----
wrighty (Guest)
on 2005-11-16 18:26
(Received via mailing list)
If there is a solution to this then I'd be very interested to hear it.
 I spent a while with Kyle in irc trying to work though this issue but
in the end we settled on the non-DRY doubling up on routes as at least
it works and allows non-Rails requests to be handled straight by
apache which to me seems to be the Right Thing.

I think it could be solved but it would require someone with intimate
routes knowledge to know where to add in the prefix automatically when
routes are loaded.  Kyle tried a number of approaches but he seemed to
always hit the problem that routes had already been loaded or could
only be loaded once.

Maybe the new plugin interface exposes some useful stuff?

Paul.
trevor (Guest)
on 2005-11-16 19:27
(Received via mailing list)
Guys,

this didn't affect me on my OSX box running apache 1 for some reason
(as in I didn't need to double up on the connect calls).

However, it *does* seem to be required on my apache 2 on linux server.

I've got the guts of a plugin working 50% to fix this.  I'll ping when
it's done.

Regards,
Trevor


On 16-Nov-05, at 8:25 AM, Paul W. wrote:

> only be loaded once.
>> can tell,
>>
>> bypass running SCGI, which is how caching works.
>> to double up
>>
>>
>> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Trevor S.
http://somethinglearned.com
mortonda (Guest)
on 2005-11-16 20:39
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul W. wrote:

> I think it could be solved but it would require someone with intimate
> routes knowledge to know where to add in the prefix automatically when
> routes are loaded.  Kyle tried a number of approaches but he seemed to

This is the route (pun not intended) I was thinking of, but when I
looked at the
routing code, I was thoroughly confused.  I'm anxious to see what Trevor
has
going with his plugin...

- --
David M.
Maia Mailguard                        - http://www.maiamailguard.com
Morton Software Design and Consulting - http://www.dgrmm.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDe3yBSIxC85HZHLMRAjsMAJ9Yp5eNGKd8g5ODb3Az/oszHorhpQCgmNkO
YqSkS3XUSp5TmqR53C2M/GU=
=5HOc
-----END PGP SIGNATURE-----
trevor (Guest)
on 2005-11-17 00:29
(Received via mailing list)
I've completed a plugin that fixes this for me - it works fine on my
install of typo.

I'd rather not release it before it's tested by at least one other
person so if anyone is interested in testing it, please contact me
off-list.

Regards,
Trevor

On 16-Nov-05, at 8:25 AM, Paul W. wrote:

> only be loaded once.
>> can tell,
>>
>> bypass running SCGI, which is how caching works.
>> to double up
>>
>>
>> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Trevor S.
http://somethinglearned.com
This topic is locked and can not be replied to.