Hi List, Searching through the Dancer sources, I find that bin/dancer, the app generator utility, installs a dispatch.fcgi. Having duly run bin/dancer, I have generated a public/dispatch.fcgi that I can assume will solve my problem. It seems possible possible that dispatch.fcgi could get mangled somehow, and also possible that not everyone who maintains a Dancer deployment will have experience creating a site with bin/dancer. I think that including the short code for dispatch.fcgi (and dispatch.cgi) in Dancer::Deployment would help someone troubleshooting (would have helped me today), and would be useful as a reference. On Tue, Nov 14, 2017 at 11:17:49AM -1000, Joel Roth wrote:
Hi List,
I have a web application at Dreamhost.com that I'm trying to convert to fastcgi. Under CGI, the application runs via perlbrew using a self-compiled perl.
In the Apache 2 error log, I'm getting
[Mon Nov 13 13:31:53 2017] [error] [client 98.150.189.73] Premature end of script headers: dispatch.fcgi
When I run the script dispatch.fcgi, it brings up the Dancer HTTP server:
HTTP::Server::PSGI: Accepting connections at http://0:5000/
From the Dreamhost docs[1,2] and using the supplied test script, I don't need to modify the Apache configuration. The only changes I made to the original dispatch.cgi -- gleaned from Dancer::Deployment -- were updating the script name and mod_rewrite rule.
File listings that make up my deployment follow. I don't grok is how running dispatch.fcgi, which ends in an 'exec', relates to an existing, persistent Dancer process. Perhaps Plack::Runner->run() should receive a coderef rather than a filename? I tried, but received the same the error message. I greatly welcome any suggestions!
1. https://help.dreamhost.com/hc/en-us/articles/217298967-FastCGI-overview 2. https://help.dreamhost.com/hc/en-us/articles/216512598-Perl-overview
cd dev.childspacemethod.com ls -l -rwxrwxr-x 1 childspace pg2527812 81 Nov 13 13:33 dispatch.fcgi -rw-r--r-- 1 childspace pg2527812 157 Nov 13 12:40 .htaccess -rwxrwxr-x 1 childspace pg2527812 155 Nov 13 12:47 plack_runner.pl
cat .htaccess
# BEGIN dancer application htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*) dispatch.fcgi/$1 # END dancer application htaccess
cat dispatch.fcgi
#!/bin/sh source ~/.bashrc perlbrew use 5.16.3 exec `dirname $0`/plack_runner.pl
cat plack_runner.pl
#!/usr/bin/env perl use Modern::Perl; use Plack::Runner; use autodie; chdir '/home/childspace/dev'; Plack::Runner->run('dance.psgi');
cat /home/childspace/dev/dance.psgi
#!/usr/bin/env perl BEGIN { push @ARGV, qw(--environment=production) } use Modern::Perl; use Dancer; load_app 'Training::Resources'; dance;
-- Joel Roth