Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Configuration based on hostname

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


mihai at bazon

Jul 11, 2009, 11:35 PM

Post #1 of 9 (1544 views)
Permalink
Configuration based on hostname

Hi folks,

I think this was raised before but I don't remember to have seen a
satisfactory answer. Someone please point me into the right direction.

I want to deploy a Catalyst app that will be used to serve multiple
websites. The platform will be Apache2 (prefork) + mod_perl2. I want
Catalyst to read a different configuration file, based on the host name.
Each virtual host will have its own database (configured in .conf) and
its own "root" directory, but other than this, all the Perl modules are
the same.

I know this can be done with FastCGI by launching a different process
for each host, but I'm interested in a mod_perl solution. Is it
feasible?

Cheers,
-Mihai
_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


diment at gmail

Jul 12, 2009, 12:15 AM

Post #2 of 9 (1457 views)
Permalink
Re: Configuration based on hostname [In reply to]

On 12/07/2009, at 4:35 PM, Mihai Bazon wrote:

> Hi folks,
>
> I think this was raised before but I don't remember to have seen a
> satisfactory answer. Someone please point me into the right
> direction.
>
> I want to deploy a Catalyst app that will be used to serve multiple
> websites. The platform will be Apache2 (prefork) + mod_perl2. I want
> Catalyst to read a different configuration file, based on the host
> name.
> Each virtual host will have its own database (configured in .conf) and
> its own "root" directory, but other than this, all the Perl modules
> are
> the same.
>
> I know this can be done with FastCGI by launching a different process
> for each host, but I'm interested in a mod_perl solution. Is it
> feasible?


One of the limitations of mod_perl is that you can't run the same app
more than once on the same server. Sorry.




_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


mihai at bazon

Jul 12, 2009, 12:29 AM

Post #3 of 9 (1468 views)
Permalink
Re: Configuration based on hostname [In reply to]

Kieren Diment <diment [at] gmail> wrote:
>
> On 12/07/2009, at 4:35 PM, Mihai Bazon wrote:
>
> > Hi folks,
> >
> > I think this was raised before but I don't remember to have seen a
> > satisfactory answer. Someone please point me into the right
> > direction.
> >
> > I want to deploy a Catalyst app that will be used to serve multiple
> > websites. The platform will be Apache2 (prefork) + mod_perl2. I want
> > Catalyst to read a different configuration file, based on the host
> > name.
> > Each virtual host will have its own database (configured in .conf) and
> > its own "root" directory, but other than this, all the Perl modules
> > are
> > the same.
> >
> > I know this can be done with FastCGI by launching a different process
> > for each host, but I'm interested in a mod_perl solution. Is it
> > feasible?
>
>
> One of the limitations of mod_perl is that you can't run the same app
> more than once on the same server. Sorry.

Let me clarify that. I don't want to run the app more than once. I
just want the application to switch configuration file and database
depending on the hostname that each particular request targets.

I've done this a zillion times with plain mod_perl, I just don't know
what's the proper route with Catalyst.

Cheers,
-Mihai
_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


diment at gmail

Jul 12, 2009, 12:54 AM

Post #4 of 9 (1460 views)
Permalink
Re: Configuration based on hostname [In reply to]

On 12/07/2009, at 5:29 PM, Mihai Bazon wrote:

> Kieren Diment <diment [at] gmail> wrote:
>>
>> On 12/07/2009, at 4:35 PM, Mihai Bazon wrote:
>>
>>> Hi folks,
>>>
>>> I think this was raised before but I don't remember to have seen a
>>> satisfactory answer. Someone please point me into the right
>>> direction.
>>>
>>> I want to deploy a Catalyst app that will be used to serve multiple
>>> websites. The platform will be Apache2 (prefork) + mod_perl2. I
>>> want
>>> Catalyst to read a different configuration file, based on the host
>>> name.
>>> Each virtual host will have its own database (configured in .conf)
>>> and
>>> its own "root" directory, but other than this, all the Perl modules
>>> are
>>> the same.
>>>
>>> I know this can be done with FastCGI by launching a different
>>> process
>>> for each host, but I'm interested in a mod_perl solution. Is it
>>> feasible?
>>
>>
>> One of the limitations of mod_perl is that you can't run the same app
>> more than once on the same server. Sorry.
>
> Let me clarify that. I don't want to run the app more than once. I
> just want the application to switch configuration file and database
> depending on the hostname that each particular request targets.
>
> I've done this a zillion times with plain mod_perl, I just don't know
> what's the proper route with Catalyst.

Possibly to pick up some particular config that's chosen on the basis
of the value of $c->req->host?

$c->config( host_config => {example.com => [qw/foo bar/],
superbad.com => [qw/
fred wilma/}

Or if you need something more dynamic, put some configuration grabbing
routine in auto in Controller::Root.





_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


edencardim at gmail

Jul 13, 2009, 4:44 AM

Post #5 of 9 (1452 views)
Permalink
Re: Configuration based on hostname [In reply to]

On Sun, Jul 12, 2009 at 4:29 AM, Mihai Bazon<mihai [at] bazon> wrote:
> Let me clarify that.  I don't want to run the app more than once.  I
> just want the application to switch configuration file and database
> depending on the hostname that each particular request targets.

I tend to do:

$c->config->{'Plugin::ConfigLoader'}{config_local_suffix} = hostname();

that way, you can set up your app-wide config in myapp.conf and the
host specific config in myapp_hostname.conf

--
Eden Cardim Need help with your Catalyst or DBIx::Class project?
Code Monkey http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://edenc.vox.com/ http://www.shadowcat.co.uk/servers/

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


catalyst at fadetoblack

Jul 13, 2009, 6:57 AM

Post #6 of 9 (1440 views)
Permalink
Re: Configuration based on hostname [In reply to]

> One of the limitations of mod_perl is that you can't run the same app
> more than once on the same server. Sorry.

Not true. We run multiple versions of the same app in the same apache
process.

Look at the +Parent option, which will create additional separate perl
interpreters within the same apache process on a per-virtual-host basis.

However I'd say it's more useful for running separate versions of code using
the same namespace than running the same app across multiple domains.

Carl


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


catalyst at fadetoblack

Jul 13, 2009, 7:02 AM

Post #7 of 9 (1438 views)
Permalink
Re: Configuration based on hostname [In reply to]

Mihai Bazon wrote:
> Let me clarify that. I don't want to run the app more than once. I
> just want the application to switch configuration file and database
> depending on the hostname that each particular request targets.
>
> I've done this a zillion times with plain mod_perl, I just don't know
> what's the proper route with Catalyst.

We do it with multiple vhosts running the same catalyst app, then in
Root->auto of the app we check

$c->apache->server->server_hostname

which provides the servername for the vhost as in the apache config.
Checking the ServerName means that we can ignore any alternate domains
configured using a ServerAlias directive.

Carl


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


mdietrich at cpan

Jul 17, 2009, 7:33 AM

Post #8 of 9 (1378 views)
Permalink
Re: Configuration based on hostname [In reply to]

Hi,

Am 13.07.2009 um 15:57 schrieb Carl Johnstone:

> Look at the +Parent option, which will create additional separate perl
> interpreters within the same apache process on a per-virtual-host
> basis.

where can I find information about this +Parent option?

matt

--
rainboxx Matthias Dietrich
Freier Software Engineer

rainboxx | Tel.: +49 (0) 151 / 50 60 78 64
Tölzer Str. 19 | Mail: matt [at] rainboxx
70372 Stuttgart | WWW : http://www.rainboxx.de

XING: https://www.xing.com/profile/Matthias_Dietrich18
GULP: http://www.gulp.de/profil/rainboxx.html
Attachments: PGP.sig (0.19 KB)


chisel at herlpacker

Jul 17, 2009, 8:07 AM

Post #9 of 9 (1373 views)
Permalink
Re: Configuration based on hostname [In reply to]

On Fri, Jul 17, 2009 at 04:33:59PM +0200, Matthias Dietrich wrote:
> where can I find information about this +Parent option?

http://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_

--
Chisel Wright
e: chisel [at] herlpacker
w: http://www.herlpacker.co.uk/

What do you call a chav in a box?
Innit.

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.