Topic: Passenger and Apache2 for Rails

Hello World,

I have a strange error message on my web server. I installed passenger to upload files and follow the status. All was working well but sometimes, I see this error message :

Errno::ENOENT (No such file or directory - public/data/toto.zip):
    /app/models/datafile.rb:8:in `initialize'
    /app/models/datafile.rb:8:in `open'
    /app/models/datafile.rb:8:in `save'
    /app/controllers/admin/upload_controller.rb:15:in `create'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/base.rb:1101:in `send'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/base.rb:1101:in `perform_action_without_filters'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/filters.rb:696:in `call_filters'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/filters.rb:688:in `perform_action_without_benchmark'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
    /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/rescue.rb:83:in `passenger_orig_perform_action'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/request_handler.rb:64:in `perform_action'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/base.rb:435:in `send'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/base.rb:435:in `process_without_filters'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/filters.rb:684:in `process_without_session_management_support'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/session_management.rb:114:in `process'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/base.rb:334:in `process'
    /usr/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:41:in `dispatch'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/request_handler.rb:49:in `process_request'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_request_handler.rb:206:in `main_loop'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/application_spawner.rb:376:in `start_request_handler'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/application_spawner.rb:334:in `handle_spawn_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/utils.rb:182:in `safe_fork'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/application_spawner.rb:332:in `handle_spawn_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:351:in `__send__'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:351:in `main_loop'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:195:in `start_synchronously'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:162:in `start'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/application_spawner.rb:213:in `start'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:261:in `spawn_rails_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:254:in `spawn_rails_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:153:in `spawn_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:286:in `handle_spawn_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:351:in `__send__'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:351:in `main_loop'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:195:in `start_synchronously'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/bin/passenger-spawn-server:61


Rendering /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/templates/rescues/layout.rhtml (500 Internal Error)

I have no error in my apache logs.

This is what I have on my Datafile.rb :

def self.save(upload)
    name = upload['datafile'].original_filename
    directory = "public/data"
   
    path = File.join(directory, name)
    File.open(path, "w+") {|f| f.write(upload['datafile'].read)}
  end

Sometimes all is working well, sometimes not.

So, it would be pretty cool to point the problem (logs I know don't tell anything).

Thanks to help me to figure it out.

Ask for details you would need

Re: Passenger and Apache2 for Rails

That is definitely strange. What Linux distro is this on?

Also what version of Ruby, Rails, Passenger, Apache are you using? Also what DBMS and it's version are you using?

Re: Passenger and Apache2 for Rails

Gentoo Base System release 1.12.11.1
ruby 1.8.6 (2009-06-08 patchlevel 369) [i486-linux]
Rails 1.2.6

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/ext/apache2/mod_passenger.so
LoadModule upload_progress_module /usr/lib/apache2/modules/mod_upload_progress.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4
PassengerRuby /usr/bin/ruby18

Server version: Apache/2.2.11 (Unix)
Server built:   Jul 21 2009 11:24:18

and finally

Your MySQL connection id is 229
Server version: 5.0.70-log Gentoo Linux mysql-5.0.70-r1


thx in adv.

Re: Passenger and Apache2 for Rails

Has it always intermittently done this?

Re: Passenger and Apache2 for Rails

I think so jmbrink26

I was thinking a bad apache configuration, so I was restarted it. But I would like to figure it out now it is still not working well and the only error message is in my development.log and not in my apache error.log or access.log.

Re: Passenger and Apache2 for Rails

Have you noticed any system events like CPU spikes, network hiccups, things of that nature occur when this happens?

Re: Passenger and Apache2 for Rails

Anything about this sad

All is "normal" until this message, I see entry in the access.log and nothing in the error.log in both cases.

Re: Passenger and Apache2 for Rails

Ok, everything I've found so far searching for just the generic message "Errno::ENOENT (No such file or directory -", most of the results I found had to do with things not being available to where they should be like a directory that no longer existed, or a socket that doesn't exist, things like that.

So that leads me to believe that when this intermittently happens, that directory is becoming unavailable temporarily. So it's a matter of determining why, which doesn't get us much farther here... tongue

Now, is the directory in question a local directory, or is it a mounted directory from either another hard drive, or perhaps over NFS, SSHFS, SMB/CIFS, FTP, etc...?

Re: Passenger and Apache2 for Rails

# df -hl
Sys. de fich.         Tail. Occ. Disp. %Occ. Mont? sur
/dev/md1              5,0G  2,9G  1,9G  62% /
udev                   10M  164K  9,9M   2% /dev
/dev/md2              454G  139G  292G  33% /home
shm                  1005M     0 1005M   0% /dev/shm

# Directory where files are normally created
drwxr-xr-x 2 www-data www-data 4096 nov  3 10:03 data

# du -hs /tmp/
797M    /tmp/
# ls -l /tmp/
total 816096
-rw------- 1 www-data www-data        30 oct 16 15:57 CGI.13040.0
-rw------- 1 www-data www-data   8532643 oct 16 15:57 CGI.13040.1
-rw------- 1 www-data www-data        30 oct 27 11:53 CGI.13582.0
-rw------- 1 www-data www-data  56716474 oct 27 11:53 CGI.13582.1
-rw------- 1 www-data www-data        30 oct 16 16:27 CGI.20741.0
-rw------- 1 www-data www-data   8532643 oct 16 16:27 CGI.20741.1
-rw------- 1 www-data www-data        30 oct 29 11:45 CGI.31201.0
-rw------- 1 www-data www-data 761016816 oct 29 11:46 CGI.31201.1
-rw------- 1 www-data www-data        30 oct 16 11:26 CGI.4631.2
d-ws--x--x 6 root     root          4096 nov  2 10:51 passenger.19372
-rw-r--r-- 1 root     root             4 nov  2 10:51 upload_progress_cache

Directory is available, I think the problem is from CGI.

And the apache configuration file is well set

<VirtualHost *:80>
        ServerName name.host.com
        DocumentRoot /var/www/webapps/encodage/public
        <Directory "/var/www/webapps/encodage/public">
                Options Indexes Multiviews
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>
        <Location />
                TrackUploads On
        </Location>
        <Location /progress>
                ReportUploads On
        </Location>
</VirtualHost>


Thx again for help

Re: Passenger and Apache2 for Rails

Perhaps it may be the CGI. However, if you are running Passenger, why are you bothering with CGI or FastCGI? That's the reason Passenger was made, so CGI is no longer needed to get Rails working with Apache.

Here is what one of my Virtualhost files looks like for Apache 2:

<VirtualHost *:80>

  ServerName iloveorganic.co.uk
  
  DocumentRoot /var/www/sites/iloveorganic/public
  RailsEnv development
</VirtualHost>

I tend to stay relatively simple with mine, and only add more when needed. wink

What does your /etc/apache2/apache2.conf or httpd.conf look like?

Re: Passenger and Apache2 for Rails

jmbrink26 wrote:

That is definitely strange. What Linux distro is this on?

Also what version of Ruby, Rails, Passenger, Apache are you using? Also what DBMS and it's version are you using?


Hi all, I am a new member of forum. Would a newcomer be warmly welcome here? Good day you guys!!!

__________________
Watch Anime Episodes

Re: Passenger and Apache2 for Rails

Hi, welcome to the forum. big_smile You are definitely most welcome here.

Have some questions or insight you need some guidance or help on?

Re: Passenger and Apache2 for Rails

I changed my process to upload my files via FTP. It is a better solution safer. Thx for help again

Re: Passenger and Apache2 for Rails

Sounds good. Glad I could help. smile