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

Mailing List Archive: Catalyst: Users

Troubleshooting FastCGI error

 

 

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


paikkos at googlemail

Aug 13, 2008, 3:08 AM

Post #1 of 13 (1501 views)
Permalink
Troubleshooting FastCGI error

Hi,

I have an odd problem with my tiny app. Under server script
(MyApp/script/myapp_server -d) it runs without error. However under
fascgi I am encountering a problem with one of my controllers that
uses a FormFU. There an abridged version of the controller is pasted
below.


sub edit : Local :FormConfig('record_data/edit.yml') {
my ($self, $c, $id) = @_;
my $record_data = $c->model('MyAppDB::record_data')->find({'sub_id' => $id});
unless($record_data) {
$c->flash->{error_msg} = "Invalid submission $id -- Cannot edit";
$c->response->redirect($c->uri_for('/submissions/list'));
$c->detach;
}
my $form = $c->stash->{form};
# Update the HD and display the checkbox as checked.
if ($record_data->sub_id->hasHD == 1) {
my $watermarked = $form->get_field({name => 'hasHD'});
$watermarked->checked($record_data->sub_id->hasHD);
}
...
if ($form->submitted_and_valid) {
# create an entry
# Update the validation flag on the submission
$record_data->sub_id->update({validation_pass => 1}); #
Line 89. This line cause CascadeActions::update() error
# Update the record_data
$form->model->update($record_data); # This line causes
Row::update_or_insert() error
$c->flash->{status_msg} = 'metadata updated';
$c->response->redirect($c->uri_for('/submissions/list'));
$c->detach;
}
else {
$form->model->default_values($record_data);
}
$c->stash->{template} = 'submissions/edit.tt2';
}


The controller loads the data from $c->model('MyAppDB::record_data')
fine and displays it in the form. It's when you attempt the
update/submit you get the error. So the issue seems to be with
$form->model->update($record_data);

My conf file has:

<Model::FormFu>
stash_key form
</Model::FormFu>


The error in the http error log is:
:CascadeActions::update(): DBI Exception: DBD::SQLite::st execute
failed: unable to open database file(14) at dbdimp.c line 403 [for
Statement "UPDATE submissions SET validation_pass = ? WHERE ( id = ?
)"] at ..lib/MyApp/Controller/RecordData.pm line 89, referer: ...

DBIx::Class::Row::update_or_insert(): DBI Exception: DBD::SQLite::st
execute failed: unable to open database file(14) at dbdimp.c line 403
[for Statement "UPDATE clipData SET audio = ? WHERE ( id = ? )"] at
/usr/lib/perl5/site_perl/5.8.8/HTML/FormFu/Model/DBIC.pm line 324,


Server configuration.

DocumentRoot /var/www/MyApp/root
Alias /static /var/www/MyApp/root/static

FastCgiServer /var/www/MyApp/script/myapp_fastcgi.pl -processes 3
Alias /motion /var/www/MyApp/script/myapp_fastcgi.pl/

Does anyone have any ideas what the problem might be? I can't see why
it might work in one environment and not the other.
Tia,
Dp.

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


robertkrimen at gmail

Aug 13, 2008, 3:24 AM

Post #2 of 13 (1475 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

On Wed, Aug 13, 2008 at 3:08 AM, Dermot <paikkos[at]googlemail.com> wrote:

> Hi,
>
> I have an odd problem with my tiny app. Under server script
> (MyApp/script/myapp_server -d) it runs without error. However under
> fascgi I am encountering a problem with one of my controllers that
> uses a FormFU. There an abridged version of the controller is pasted
> below.
>
> The error in the http error log is:
> :CascadeActions::update(): DBI Exception: DBD::SQLite::st execute
> failed: unable to open database file(14) at dbdimp.c line 403 [for
> Statement "UPDATE submissions SET validation_pass = ? WHERE ( id = ?
> )"] at ..lib/MyApp/Controller/RecordData.pm line 89, referer: ...
>
> DBIx::Class::Row::update_or_insert(): DBI Exception: DBD::SQLite::st
> execute failed: unable to open database file(14) at dbdimp.c line 403
> [for Statement "UPDATE clipData SET audio = ? WHERE ( id = ? )"] at
> /usr/lib/perl5/site_perl/5.8.8/HTML/FormFu/Model/DBIC.pm line 324,
>
> Server configuration.
>
> DocumentRoot /var/www/MyApp/root
> Alias /static /var/www/MyApp/root/static
>
> FastCgiServer /var/www/MyApp/script/myapp_fastcgi.pl -processes 3
> Alias /motion /var/www/MyApp/script/myapp_fastcgi.pl/
>
> Does anyone have any ideas what the problem might be? I can't see why
> it might work in one environment and not the other.
>

This looks like a permissions issue to me. You're running the "server
script" as one
user and then running the application via Apache (which is a different user
like nobody or www).

Apache doesn't have write (or maybe even read) access to your SQLite
database file or directory.

Rob


paikkos at googlemail

Aug 13, 2008, 3:35 AM

Post #3 of 13 (1474 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

>> DBIx::Class::Row::update_or_insert(): DBI Exception: DBD::SQLite::st
>> execute failed: unable to open database file(14) at dbdimp.c line 403
>> [for Statement "UPDATE clipData SET audio = ? WHERE ( id = ? )"] at
>> /usr/lib/perl5/site_perl/5.8.8/HTML/FormFu/Model/DBIC.pm line 324,
>>
>> Server configuration.
>>
>> DocumentRoot /var/www/MyApp/root
>> Alias /static /var/www/MyApp/root/static
>>
>> FastCgiServer /var/www/MyApp/script/myapp_fastcgi.pl -processes 3
>> Alias /motion /var/www/MyApp/script/myapp_fastcgi.pl/
>>
>> Does anyone have any ideas what the problem might be? I can't see why
>> it might work in one environment and not the other.
>
> This looks like a permissions issue to me. You're running the "server
> script" as one
> user and then running the application via Apache (which is a different user
> like nobody or www).
>
> Apache doesn't have write (or maybe even read) access to your SQLite
> database file or directory.
>
> Rob

Thanx Rob but chmod was the first thing I did.

-rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db

Changing the owner/group hasn't helped either.

I am not sure but I would have expected a permission denied message if
the permissions were incorrect. This reads more like file not found.

Thanx,
Dp.

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


matthias.zeichmann at gmail

Aug 13, 2008, 3:43 AM

Post #4 of 13 (1475 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

On Wed, Aug 13, 2008 at 12:35, Dermot <paikkos[at]googlemail.com> wrote:
> -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db

better change permissions to something like 664 and chgrp www-data (or
whatever your webserver runs as) and make sure that webserver user can
traverse the path to db

like i.e.
# su -m www-data
$ cd $PATH_TO_YOUR_DB

cheers
m
--
siggen.pl: Segmentation Fault

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


paikkos at googlemail

Aug 13, 2008, 4:08 AM

Post #5 of 13 (1472 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

2008/8/13 Matthias Zeichmann <matthias.zeichmann[at]gmail.com>:
> On Wed, Aug 13, 2008 at 12:35, Dermot <paikkos[at]googlemail.com> wrote:
>> -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db
>
> better change permissions to something like 664 and chgrp www-data (or
> whatever your webserver runs as) and make sure that webserver user can
> traverse the path to db
>
> like i.e.
> # su -m www-data
> $ cd $PATH_TO_YOUR_DB
>
> cheers
> m

Hi Matthias,

Is that for security reason? My http daemon runs as apache. Below is
the permissions as they are now.

-rw-r-xr-- 1 apache apache 793600 Aug 12 13:30 mydata.db

It doesn't resolve my problem. The error:

unable to open database file(14)

Is still there, even after a graceful restart.

I suspect this is a configuration problem with FormFU but I am not
sure what. I have tickered with my conf file

name MyApp
...
<Model::FormFu>
config_dir __HOME__
stash_key form
</Model::FormFu>
..

but that doesn't appear to make a difference.
Thanx,
Dp.

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


fireartist at gmail

Aug 13, 2008, 4:28 AM

Post #6 of 13 (1468 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

2008/8/13 Dermot <paikkos[at]googlemail.com>:
> 2008/8/13 Matthias Zeichmann <matthias.zeichmann[at]gmail.com>:
>> On Wed, Aug 13, 2008 at 12:35, Dermot <paikkos[at]googlemail.com> wrote:
>>> -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db
>>
>> better change permissions to something like 664 and chgrp www-data (or
>> whatever your webserver runs as) and make sure that webserver user can
>> traverse the path to db
>>
>> like i.e.
>> # su -m www-data
>> $ cd $PATH_TO_YOUR_DB
>>
>> cheers
>> m
>
> Hi Matthias,
>
> Is that for security reason? My http daemon runs as apache. Below is
> the permissions as they are now.
>
> -rw-r-xr-- 1 apache apache 793600 Aug 12 13:30 mydata.db
>
> It doesn't resolve my problem. The error:
>
> unable to open database file(14)
>
> Is still there, even after a graceful restart.
>
> I suspect this is a configuration problem with FormFU but I am not
> sure what. I have tickered with my conf file

You're passing $form->model->update() your row object, so I don't
think it can be a problem with formfu, as it'll just be working with
that.
Did you follow Matthias' advice to `su apache` and check you can
change into the directory containing the db file?

Carl

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


paikkos at googlemail

Aug 13, 2008, 4:40 AM

Post #7 of 13 (1469 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

2008/8/13 Carl Franks <fireartist[at]gmail.com>:
> 2008/8/13 Dermot <paikkos[at]googlemail.com>:
>> 2008/8/13 Matthias Zeichmann <matthias.zeichmann[at]gmail.com>:
>>> On Wed, Aug 13, 2008 at 12:35, Dermot <paikkos[at]googlemail.com> wrote:
>>>> -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db
>>>
>>> better change permissions to something like 664 and chgrp www-data (or
>>> whatever your webserver runs as) and make sure that webserver user can
>>> traverse the path to db
>>>
>>> like i.e.
>>> # su -m www-data
>>> $ cd $PATH_TO_YOUR_DB
>>>
>>> cheers
>>> m
>>
>> Hi Matthias,
>>
>> Is that for security reason? My http daemon runs as apache. Below is
>> the permissions as they are now.
>>
>> -rw-r-xr-- 1 apache apache 793600 Aug 12 13:30 mydata.db
>>
>> It doesn't resolve my problem. The error:
>>
>> unable to open database file(14)
>>
>> Is still there, even after a graceful restart.
>>
>> I suspect this is a configuration problem with FormFU but I am not
>> sure what. I have tickered with my conf file
>
> You're passing $form->model->update() your row object, so I don't
> think it can be a problem with formfu, as it'll just be working with
> that.
> Did you follow Matthias' advice to `su apache` and check you can
> change into the directory containing the db file?
>
> Carl

Thanx Carl and Sorry Matthias, I didn't follow you exactly because

su apache
This account is currently not available

and

su -m apache
bash: /root/.bashrc: Permission denied

So I have chown apache:apache MyApp directory and it works.

Is it okay to leave the top level directory and the datafile owned by
the httpd user? I would have thought all the other code should be
read-only for other that user.

Thanx again,
Dp.

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


iain.hubbard at gmgrd

Aug 13, 2008, 5:00 AM

Post #8 of 13 (1465 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

On Wed, 2008-08-13 at 11:35 +0100, Dermot wrote:
> I am not sure but I would have expected a permission denied message if
> the permissions were incorrect. This reads more like file not found.

A quick google turned up a similar problem
http://www.perlmonks.org/?node_id=695467

This turned out to be a permissions problem.

Iain.
--------------------------------------------------------
GMG Regional Digital is part of the Guardian Media Group plc.




CONFIDENTIALITY NOTICE. The information contained in this e-mail is intended only for catalyst[at]lists.scsys.co.uk. It may contain privileged and confidential information that is exempt from disclosure by law and if you are not an intended recipient, you must not copy, distribute or take any action in reliance on it. If you have received this e-mail in error, you may notify us by telephone on 44 (0)161 832 7200. E-mail transmission cannot be guaranteed to be secure or error-free. The sender (iain.hubbard[at]gmgrd.co.uk) therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.

Scanned by MailDefender - managed email security from intY - www.maildefender.net

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


paikkos at googlemail

Aug 13, 2008, 5:52 AM

Post #9 of 13 (1462 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

2008/8/13 Iain Hubbard <iain.hubbard[at]gmgrd.co.uk>:
> On Wed, 2008-08-13 at 11:35 +0100, Dermot wrote:
>> I am not sure but I would have expected a permission denied message if
>> the permissions were incorrect. This reads more like file not found.
>
> A quick google turned up a similar problem
> http://www.perlmonks.org/?node_id=695467
>
> This turned out to be a permissions problem.
>
> Iain.
> --------------------------------------------------------
> GMG Regional Digital is part of the Guardian Media Group plc.
>
>
>
>
> CONFIDENTIALITY NOTICE. The information contained in this e-mail is intended only for catalyst[at]lists.scsys.co.uk. It may contain privileged and confidential information that is exempt from disclosure by law and if you are not an intended recipient, you must not copy, distribute or take any action in reliance on it. If you have received this e-mail in error, you may notify us by telephone on 44 (0)161 832 7200. E-mail transmission cannot be guaranteed to be secure or error-free. The sender (iain.hubbard[at]gmgrd.co.uk) therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.
>
> Scanned by MailDefender - managed email security from intY - www.maildefender.net

If your suggesting that I didn't try that, your mistaken.

I searched for "fastcgi" at
http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/

and didn't see anything relevant.

Thanx,
Dp.

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


dbix-class at trout

Aug 17, 2008, 10:49 AM

Post #10 of 13 (1357 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

On Wed, Aug 13, 2008 at 12:40:13PM +0100, Dermot wrote:
> So I have chown apache:apache MyApp directory and it works.
>
> Is it okay to leave the top level directory and the datafile owned by
> the httpd user? I would have thought all the other code should be
> read-only for other that user.

If you use FastCgiExternalServer you can run the app as its own user.

That's what I usually do.

--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/

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


marcus at nordaaker

Aug 28, 2008, 12:05 PM

Post #11 of 13 (1103 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

On 13. aug.. 2008, at 13.40, Dermot wrote:
>
> Thanx Carl and Sorry Matthias, I didn't follow you exactly because
>
> su apache
> This account is currently not available
>
> and
>
> su -m apache
> bash: /root/.bashrc: Permission denied
>
> So I have chown apache:apache MyApp directory and it works.
>
> Is it okay to leave the top level directory and the datafile owned by
> the httpd user? I would have thought all the other code should be
> read-only for other that user.

SQLite requires write access on the directory the data file is in as
well as the data file to be able to provide locking. leaving the app
writeable by the httpd user isn't really recommended. I suggest moving
your sqlite database to a db directory or something similar.

Marcus

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


paikkos at googlemail

Aug 28, 2008, 1:18 PM

Post #12 of 13 (1100 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

2008/8/28 Marcus Ramberg <marcus[at]nordaaker.com>:
>
> On 13. aug.. 2008, at 13.40, Dermot wrote:
>>
>> Thanx Carl and Sorry Matthias, I didn't follow you exactly because
>>
>> su apache
>> This account is currently not available
>>
>> and
>>
>> su -m apache
>> bash: /root/.bashrc: Permission denied
>>
>> So I have chown apache:apache MyApp directory and it works.
>>
>> Is it okay to leave the top level directory and the datafile owned by
>> the httpd user? I would have thought all the other code should be
>> read-only for other that user.
>
> SQLite requires write access on the directory the data file is in as well as
> the data file to be able to provide locking. leaving the app writeable by
> the httpd user isn't really recommended. I suggest moving your sqlite
> database to a db directory or something similar.
>
> Marcus

Thanx Marcus. That's useful to know.
Dp.

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


Wade.Stuart at fallon

Aug 28, 2008, 2:47 PM

Post #13 of 13 (1097 views)
Permalink
Re: Troubleshooting FastCGI error [In reply to]

Marcus Ramberg <marcus[at]nordaaker.com> wrote on 08/28/2008 02:05:44 PM:

>
> On 13. aug.. 2008, at 13.40, Dermot wrote:
> >
> > Thanx Carl and Sorry Matthias, I didn't follow you exactly because
> >
> > su apache
> > This account is currently not available

look at your apache users' passwd entry, you will see a shell for
/sbin/nologin (which produces that error), if you pass a valid shell to su
you can use it to run commands as apache...

#su -s /bin/sh -c "whoami" apache
apache




> >
> > and
> >
> > su -m apache
> > bash: /root/.bashrc: Permission denied
> >
> > So I have chown apache:apache MyApp directory and it works.
> >
> > Is it okay to leave the top level directory and the datafile owned by
> > the httpd user? I would have thought all the other code should be
> > read-only for other that user.
>
> SQLite requires write access on the directory the data file is in as
> well as the data file to be able to provide locking. leaving the app
> writeable by the httpd user isn't really recommended. I suggest moving
> your sqlite database to a db directory or something similar.
>
> Marcus
>
> _______________________________________________
> List: Catalyst[at]lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/


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

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


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.