Project

General

Profile

[Solved] Old Rails applications

Added by don.rawe almost 6 years ago

Hi All,

I'm new to LightTPD and am having an issue getting two old rails apps to run.

The environment is:
LightTPD 1.4.49
OS: Ubuntu 16.04.4
uname -a: Linux dominiondev 4.4.0-130-generic #156-Ubuntu SMP Thu Jun 14 08:53:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Rails 1.2.3
Ruby 1.8.5 level 52
RubyGems 0.9.2

I managed to get the first app running using the rails script/server lighttpd command with the following config file.

posmaxweb/config/lighttpd.conf

# Default configuration file for the lighttpd web server
# Start using ./script/server lighttpd

server.bind = "10.10.15.10" 
server.port = 81

server.modules           = ( "mod_rewrite", "mod_accesslog", "mod_fastcgi", "mod_compress", "mod_expire" )

server.error-handler-404 = "/dispatch.fcgi" 
server.pid-file          = CWD + "/tmp/pids/lighttpd.pid" 
server.document-root     = CWD + "/public/" 

server.errorlog          = CWD + "/log/lighttpd.error.log" 
accesslog.filename       = CWD + "/log/lighttpd.access.log" 

url.rewrite              = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )

compress.filetype        = ( "text/plain", "text/html", "text/css", "text/javascript" )
compress.cache-dir       = CWD + "/tmp/cache" 

expire.url               = ( "/favicon.ico"  => "access 3 days",
                             "/images/"      => "access 3 days",
                             "/stylesheets/" => "access 3 days",
                             "/javascripts/" => "access 3 days" )

# Change *-procs to 2 if you need to use Upload Progress or other tasks that
# *need* to execute a second request while the first is still pending.
fastcgi.server      = ( ".fcgi" => ( "localhost" => (
  "min-procs"       => 1,
  "max-procs"       => 1,
  "socket"          => CWD + "/tmp/sockets/fcgi.socket",
  "bin-path"        => CWD + "/public/dispatch.fcgi",
  "bin-environment" => ( "RAILS_ENV" => "production" )
) ) )

mimetype.assign = (
  ".css"        =>  "text/css",
  ".gif"        =>  "image/gif",
  ".htm"        =>  "text/html",
  ".html"       =>  "text/html",
  ".jpeg"       =>  "image/jpeg",
  ".jpg"        =>  "image/jpeg",
  ".js"         =>  "text/javascript",
  ".png"        =>  "image/png",
  ".swf"        =>  "application/x-shockwave-flash",
  ".txt"        =>  "text/plain" 
)

# Making sure file uploads above 64k always work when using IE or Safari
# For more information, see http://trac.lighttpd.net/trac/ticket/360
$HTTP["useragent"] =~ "^(.*MSIE.*)|(.*AppleWebKit.*)$" {
  server.max-keep-alive-requests = 0
}

The above application runs fine but the second application with the following config file results in a ruby error:

dominion/config/lighttpd.conf

# Default configuration file for the lighttpd web server
# Start using ./script/server lighttpd

server.bind = "10.10.15.10" 
server.port = 82

server.modules           = ( "mod_rewrite", "mod_accesslog", "mod_fastcgi", "mod_compress", "mod_expire" )

server.error-handler-404 = "/dispatch.fcgi" 
server.pid-file          = "/programs/dominion/tmp/pids/lighttpd.pid" 
server.document-root     = "/programs/dominion/public/" 

server.errorlog          = "/programs/dominion/log/lighttpd.error.log" 
accesslog.filename       = "/programs/dominion/log/lighttpd.access.log" 

url.rewrite              = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )

compress.filetype        = ( "text/plain", "text/html", "text/css", "text/javascript" )
compress.cache-dir       = "/programs/dominion/tmp/cache" 

expire.url               = ( "/favicon.ico"  => "access 3 days",
                             "/images/"      => "access 3 days",
                             "/stylesheets/" => "access 3 days",
                             "/javascripts/" => "access 3 days" )

# Change *-procs to 2 if you need to use Upload Progress or other tasks that
# *need* to execute a second request while the first is still pending.
fastcgi.server      = ( ".fcgi" => ( "localhost" => (
  "min-procs"       => 1,
  "max-procs"       => 1,
  "socket"          => "/programs/dominion/tmp/sockets/fcgi.socket",
  "bin-path"        => "/programs/dominion/public/dispatch.fcgi",
  "bin-environment" => ( "RAILS_ENV" => "production" )
) ) )

mimetype.assign = (
  ".css"        =>  "text/css",
  ".gif"        =>  "image/gif",
  ".htm"        =>  "text/html",
  ".html"       =>  "text/html",
  ".jpeg"       =>  "image/jpeg",
  ".jpg"        =>  "image/jpeg",
  ".js"         =>  "text/javascript",
  ".png"        =>  "image/png",
  ".swf"        =>  "application/x-shockwave-flash",
  ".txt"        =>  "text/plain" 
)

# Making sure file uploads above 64k always work when using IE or Safari
# For more information, see http://trac.lighttpd.net/trac/ticket/360
$HTTP["useragent"] =~ "^(.*MSIE.*)|(.*AppleWebKit.*)$" {
  server.max-keep-alive-requests = 0
}

The ruby error is:
/programs/dominion/public/../config/boot.rb:19:in `require': no such file to load -- rubygems (LoadError)
from /programs/dominion/public/../config/boot.rb:19
from /programs/dominion/public/../config/environment.rb:11:in `require'
from /programs/dominion/public/../config/environment.rb:11
from /programs/dominion/public/dispatch.fcgi:21:in `require'
from /programs/dominion/public/dispatch.fcgi:21

This error would seem straight forward except that rubygems is installed and is in the ruby load path. Both apps can be started with ./script/console and both run under Webrick. Why does it work in one instance but not the other?

Thanks,
Don


Replies (4)

RE: Old Rails applications - Added by gstrauss almost 6 years ago

You may need to set additional environment variables in in the Ruby environment,
e.g. add PATH or other vars to "bin-environment" => ( "RAILS_ENV" => "production" )

RE: Old Rails applications - Added by don.rawe almost 6 years ago

I don't think that will resolve anything, I've modified boot.rb to display the version of ruby and the ruby load path immediately before the require 'rubygems' line that generates the error and they are both identical and the location of rubygems.rb is the first path in the list. I've also tried modifying the RUBYLIB environment variable to contain the correct path which only causes the load path to contain the directory twice.

RE: Old Rails applications - Added by gstrauss almost 6 years ago

This error would seem straight forward except that rubygems is installed and is in the ruby load path. Both apps can be started with ./script/console and both run under Webrick. Why does it work in one instance but not the other?

If it is not related to the environment, then it might be related to filesystem permissions, or both.

Have you tried manually running the script under the user account under which lighttpd is running?

RE: Old Rails applications - Added by don.rawe almost 6 years ago

Found it, the original system the apps came from had ruby installed in /usr/bin where the new Ubuntu server has it in /usr/local/bin. I had changed the shebang in dispatch.fcgi in the working app to use /usr/local/bin/ruby but because there are a number of other programs with /usr/bin/ruby in the shebang I copied /usr/local/bin/ruby to /usr/bin to avoid finding and updating all the other programs with the incorrect shebang. Evan though both were running the same version of ruby just from different locations they behaved differently. Go Figure? Consider this closed.

Thanks

    (1-4/4)