<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 17, 2013 at 10:36 AM, Juan José 'Peco' San Martín <span dir="ltr"><<a href="mailto:jsanmartin@gmail.com" target="_blank">jsanmartin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>I have 2 different Dancer apps (app1 and app2). Each one working very well on different servers under Apache and Plack::Handler::Apache2.<br>
</div><br></div>Now, I would like put both applications in just one server, so I adjusted the Apache config just adding the two Location sections.</div>
<br><div>If I use the first app, everything works, but when I try the second one, it seems that Dancer2 (with Plack::Handler::Apache2) still looks for the paths of the first app (so it fails because it can not find my app2 modules).<br>
<br></div><div>Example (how to reproduce the behaviour)<br></div><div><br></div><div>0) Dancer 2.06<br><br></div><div>1) Adjust Apache config to add the Locations of the two apps<br><br></div><div># Apache location<br></div>
<div><div><div class="im"><Location /app1><br> SetHandler perl-script<br> PerlHandler Plack::Handler::Apache2<br></div> PerlSetVar psgi_app /path/app1/bin/<a href="http://app.pl" target="_blank">app.pl</a><br>
</Location><div class="im"><br><Location /app2><br>
SetHandler perl-script<br> PerlHandler Plack::Handler::Apache2<br></div> PerlSetVar psgi_app /path/app2/bin/<a href="http://app.pl" target="_blank">app.pl</a><br></Location><br><br></div><div>2) Try app1 => it works!<br>
<br></div>
<div>3) Try app2 => fails with the next message: Error while loading /app2/<a href="http://app.pl" target="_blank">app.pl</a>: Can't locate App2.pm in @INC (@INC contains /path/app1/lib/ /usr/local....)<br><br></div>
<div>Where App2 is the main module at (app2/lib/) called from app2/bin/<a href="http://app.pl" target="_blank">app.pl</a> after use Dancer2.<br></div></div></div></blockquote><div><br></div><div>Try this: create a merged.psgi file with this content:</div>
<div><br></div><div>use Plack::Builder;</div><div>use App1;</div><div>use App2;</div><div><br></div><div>builder {</div><div> mount '/app1' => App1->dance;</div><div><div> mount '/app2' => App2->dance;</div>
</div><div>};</div><div><br></div><div><br></div><div>And then use it on Apache with:</div><div><br></div><div><div class="im"><Location /><br> SetHandler perl-script<br> PerlHandler Plack::Handler::Apache2<br>
</div> PerlSetVar psgi_app /path/to/merged.psgi<br></Location><br></div><div><br></div><div>I have not tested this, I don't have a mod_perl2 at hand anymore, but it should work.</div><div><br></div><div>Bye,</div>
</div>-- <br>Pedro Melo<br>@pedromelo<br><a href="http://www.simplicidade.org/" target="_blank">http://www.simplicidade.org/</a><br><a href="mailto:xmpp%3Amelo@simplicidade.org" target="_blank">xmpp:melo@simplicidade.org</a><br>
mailto:<a href="mailto:melo@simplicidade.org" target="_blank">melo@simplicidade.org</a>
</div></div>