deploying via Apache
I have discovered that if I type the following in my application directory "~/Sites/dance" perl -MPlack::Runner -e"Plack::Runner->run('app.psgi')" the application runs fine. Its starts up with the prompt HTTP::Server::PSGI: Accepting connections at http://0:5000/ and I am able to see my web site at http://localhost:5000/ However, the same command invoked via dance/public/dispatch.cgi results in Error while loading /Users/punkish/Sites/dance/app.psgi: unable to load application dance : Can't locate dance.pm in @INC (@INC contains: /Users/punkish/Sites/dance/public/lib So, obviously, in spite of what the docs say, somewhere Dancer is being instructed to look for 'lib' in my application's public folder, but is failing to do so. On the other hand, Plack::Runner('app.psgi') is happily able to run without being told anything special about 'public' I am going to give this another few hours and then basically give up on Dancer and move back to CGI::Application or explore mojo. Dancer is a beautiful framework, but the grief in getting beyond the basics is just not worth it. It would be very sad and ironic if this is all because of something extremely obvious that I am overlooking. Hoping I can resolve this soon. -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science =======================================================================
On Mon, Aug 2, 2010 at 9:42 PM, P Kishor <punk.kish@gmail.com> wrote:
I have discovered that if I type the following in my application directory "~/Sites/dance"
perl -MPlack::Runner -e"Plack::Runner->run('app.psgi')"
the application runs fine. Its starts up with the prompt
HTTP::Server::PSGI: Accepting connections at http://0:5000/
and I am able to see my web site at http://localhost:5000/
Hi There is a bug in the last Dancer version on CPAN: in the app.psgi file, you need to add a "use lib 'lib'" before the load_app instruction. Let us know if this works for you. Thanks
On Mon, Aug 2, 2010 at 2:49 PM, franck <franck@lumberjaph.net> wrote:
On Mon, Aug 2, 2010 at 9:42 PM, P Kishor <punk.kish@gmail.com> wrote:
I have discovered that if I type the following in my application directory "~/Sites/dance"
perl -MPlack::Runner -e"Plack::Runner->run('app.psgi')"
the application runs fine. Its starts up with the prompt
HTTP::Server::PSGI: Accepting connections at http://0:5000/
and I am able to see my web site at http://localhost:5000/
Hi There is a bug in the last Dancer version on CPAN: in the app.psgi file, you need to add a "use lib 'lib'" before the load_app instruction. Let us know if this works for you.
Nope, it doesn't. First, I have to "use lib '/full/path/to/lib'" By using the full path, at least, lib is recognized, and Dancer is actually invoked. But, notice that I still have to go to http://localhost/dance/public/dispatch.cgi instead of http://localhost/dance/dispatch.cgi/ so that is yet another bug in the Dancer docs. But, after that, I am back to square one. Now, even though dance.pm is found, I get a 404 "Sorry this is the void"
Thanks
-- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science =======================================================================
On Mon, Aug 2, 2010 at 3:00 PM, P Kishor <punk.kish@gmail.com> wrote:
On Mon, Aug 2, 2010 at 2:49 PM, franck <franck@lumberjaph.net> wrote:
On Mon, Aug 2, 2010 at 9:42 PM, P Kishor <punk.kish@gmail.com> wrote:
I have discovered that if I type the following in my application directory "~/Sites/dance"
perl -MPlack::Runner -e"Plack::Runner->run('app.psgi')"
the application runs fine. Its starts up with the prompt
HTTP::Server::PSGI: Accepting connections at http://0:5000/
and I am able to see my web site at http://localhost:5000/
Hi There is a bug in the last Dancer version on CPAN: in the app.psgi file, you need to add a "use lib 'lib'" before the load_app instruction. Let us know if this works for you.
Nope, it doesn't. First, I have to "use lib '/full/path/to/lib'" By using the full path, at least, lib is recognized, and Dancer is actually invoked.
But, notice that I still have to go to http://localhost/dance/public/dispatch.cgi instead of http://localhost/dance/dispatch.cgi/ so that is yet another bug in the Dancer docs.
But, after that, I am back to square one. Now, even though dance.pm is found, I get a 404 "Sorry this is the void"
I should have emphasized again that if I run Plack::Runner->run('path/to/app.psgi') from the command line, I can go to http://localhost:5000/ and my application works fine. I don't even have to add the "use lib '/path/to/app/lib'" to app.psgi. It works well even without that use lib line. It is via dispatch.cgi that it just does not work. -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science =======================================================================
Hi There is a bug in the last Dancer version on CPAN: in the app.psgi file, you need to add a "use lib 'lib'" before the load_app instruction. Let us know if this works for you.
Nope, it doesn't. First, I have to "use lib '/full/path/to/lib'" By using the full path, at least, lib is recognized, and Dancer is actually invoked.
Rather than hard coding the full path to lib, why not try: use Find::Lib '../lib'; I've got that in my public/dispatch.cgi as I was running into a similar issue. I realize this isn't really the issue you're up against, but with Find::Lib you can generally avoid hard coding the full path to your libs. Olaf -- Olaf Alders olaf@wundersolutions.com http://www.wundersolutions.com http://twitter.com/wundercounter 866 503 2204 (Toll free - North America) 416 944 8306 (direct)
On Mon, Aug 2, 2010 at 3:59 PM, Olaf Alders <olaf@wundersolutions.com> wrote:
Hi There is a bug in the last Dancer version on CPAN: in the app.psgi file, you need to add a "use lib 'lib'" before the load_app instruction. Let us know if this works for you.
Nope, it doesn't. First, I have to "use lib '/full/path/to/lib'" By using the full path, at least, lib is recognized, and Dancer is actually invoked.
Rather than hard coding the full path to lib, why not try:
use Find::Lib '../lib';
I've got that in my public/dispatch.cgi as I was running into a similar issue. I realize this isn't really the issue you're up against, but with Find::Lib you can generally avoid hard coding the full path to your libs.
Thanks Olaf. As you rightly said, finding the lib is not my problem at this time. What is problematic is that Dancer's deployment apps seem to have been written without tests. As a result, there is stuff on the docs web site that causes errors even when followed to the letter. And, when I enable the app to find the lib, I still get errors. What I don't understand is, why is no one else encountering these errors that I am? My set up is fairly run of the mill, very routine. Nothing exotic at all. Yet, I am encountering errors at every step, and none of them seem to be reflected in the docs. -- Puneet Kishor
On Monday 02 August 2010 22:08:39 P Kishor wrote:
What I don't understand is, why is no one else encountering these errors that I am? My set up is fairly run of the mill, very routine. Nothing exotic at all. Yet, I am encountering errors at every step, and none of them seem to be reflected in the docs.
Maybe most people are running their apps via different methods, for instance using Apache & Plack (using Plack::Handler::Apache2 as documented at: http://search.cpan.org/dist/Dancer/lib/Dancer/Deployment.pod#Running_from_Ap... ) - I can confirm that that method definitely works for me, although I have experienced odd problems with multiple Dancer apps running that way, which I need to investigate further. Currently I have a couple of apps running via Starman with requests proxied to them via Nginx, which works beautifully for me - I intend to write up docs on that for the deployment guide soon. You're right though that, if following the details described in the docs doesn't work that we need to get that sorted. There is a QA hackathon planned soon, I would hope that testing & improving deployment instructions could be part of that. Cheers Dave P -- David Precious <davidp@preshweb.co.uk> http://blog.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/identica www.lyricsbadger.co.uk "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
On Mon, 2 Aug 2010 22:34:37 +0100, David Precious <davidp@preshweb.co.uk> wrote: [...]
You're right though that, if following the details described in the docs
doesn't work that we need to get that sorted. There is a QA hackathon planned soon, I would hope that testing & improving deployment instructions could be part of that.
I agree. Moreover, I have to say that all my energy is put into a huge refactoring work these days, I'm rewriting *a lot* of Dancer's internal in order to improve the overall design. My plan is to have that rewrite finished before the hackaton in order to be able to test deployment strategies and improve documentation and tests. So please, before switching to another framework, give us a bit of time, maybe that issue will be fixed very soon. I'ma aware Dancer is still a bit rough on the edges, but I'm sure you can understand that Dancer is a young project that has evolved very quickly; which means, it needs a bit of time to get stable. Maybe my mistake in the first place was to use a 1.x version number. I plan to release 1.2 as soon as all these polishing issues are closed. Thanks for your interest in the project anyways, I hope you can give Dancer another try when the hackaton is finished. Regards, Alexis
Thanks David. On Mon, Aug 2, 2010 at 4:34 PM, David Precious <davidp@preshweb.co.uk> wrote:
On Monday 02 August 2010 22:08:39 P Kishor wrote:
What I don't understand is, why is no one else encountering these errors that I am? My set up is fairly run of the mill, very routine. Nothing exotic at all. Yet, I am encountering errors at every step, and none of them seem to be reflected in the docs.
Maybe most people are running their apps via different methods, for instance using Apache & Plack (using Plack::Handler::Apache2 as documented at: http://search.cpan.org/dist/Dancer/lib/Dancer/Deployment.pod#Running_from_Ap... ) - I can confirm that that method definitely works for me, although I have experienced odd problems with multiple Dancer apps running that way, which I need to investigate further. ..
Ok, the Plack method works for me also, but first, my notes below, and then a comment. The Dancer docs at http://search.cpan.org/~sukria/Dancer-1.1805/lib/Dancer/Deployment.pod say Running from Apache with Plack ------------------------------ You can run your app from Apache using PSGI (Plack), with a config like the following: <VirtualHost myapp.example.com> ServerName www.myapp.example.com ServerAlias myapp.example.com DocumentRoot /websites/myapp.example.com <Location /> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /websites/myapp.example.com/app.psgi </Location> ErrorLog /websites/myapp.example.com/logs/error_log CustomLog /websites/myapp.example.com/logs/access_log common </VirtualHost> While the Plack::Handler::Apache2 docs at http://search.cpan.org/~miyagawa/Plack-0.9943/lib/Plack/Handler/Apache2.pm say <Location /> SetHandler perl-script PerlResponseHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/to/app.psgi </Location> # Optional, preload the application in the parent like startup.pl <Perl> use Plack::Handler::Apache2; Plack::Handler::Apache2->preload("/path/to/app.psgi"); </Perl> That discrepancy is confusing. The Plack docs don't mention "PerlHandler" at all, while the Dancer docs don't mention "PerlResponseHandler" at all. Those two should be reconciled one way or the other, else they are confusing. The above does work for me, but there is a huge pre-condition. I need to have mod_perl installed. See the Dancer docs (above). They don't mention that mod_perl is needed to run Dancer via Plack::Handler::Apache2. Now, this may be obvious as a brick on the head to those who know, but remember, the key selling point of Dancer is simplicity. Which means, even the complicated should be simple. Computer users are notorious for not reading the instructions, but we should at least note everything down, no matter how obvious. So, the following change to the docs would be helpful. Running from Apache with Plack ------------------------------ You can run your app from Apache using PSGI (Plack). Please note, in order to run Perl modules via Apache, you need mod_perl, so make sure mod_perl 2 or above is installed. Then, install Plack::Handler::Apache2. Finally, use the configuration below in your Apache httpd-vhosts.conf file. Finally, while I do have the above running, it is absolutely essential to have cgi mode running. I would contend that most people using shared web hosting do not have access to persistent processes such as mod_perl. They get what they get from their hosting service. Most good ones now allow installing local Perl libs, even compiled ones, or will compile standard modules for you, but none of them I know allow you to tinker with Apache. I have run my web sites with cgi for years, and they function just well. I am no Amazon. I am happy if I get 10 hits a day, so cgi speed is not a concern... its ease of deployment is an attraction. Of course, the best framework will be the one that is not only easy, but also allows multiple ways of deployment without requiring any change in the code. I think Dancer is getting there, but its docs certainly need work. -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science =======================================================================
participants (5)
-
David Precious -
franck -
Olaf Alders -
P Kishor -
sukria