LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   "/etc/init.d/apache2" start VS "apache2ctl start" with passenger module (ruby/rails) (http://www.linuxquestions.org/questions/linux-server-73/etc-init-d-apache2-start-vs-apache2ctl-start-with-passenger-module-ruby-rails-849947/)

arond 12-13-2010 10:24 AM

"/etc/init.d/apache2" start VS "apache2ctl start" with passenger module (ruby/rails)
 
Version: opensuse 11.3
Apache/2.2.17

I have a Sinatra application running on top of passenger module for Apache. Ruby 1.9.2

The application works if apache is started with "apache2ctl start", however, it doesn't when calling "service apache2 start".

The error comes from passenger:
Quote:

Error message:
invalid byte sequence in US-ASCII
Exception class:
ArgumentError

Backtrace:
# File Line Location
0 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 897 in `gsub'
1 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 897 in `inline_templates='
2 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 850 in `set'
3 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 859 in `block in enable'
4 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 859 in `each'
5 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 859 in `enable'
I'm guessing somehow apache2ctl lets passenger->ruby interpreter know that Im working with UTF-8, where service apache2 start doesn't, however I don't manage it to work even explicitally setting LANG=en_US.UTF-8 in /etc/init.d/apache2.
Any ideas on how to make service apache2 start work like apache2ctl start?

Thanks in advance

arond 12-13-2010 10:56 AM

Solved. It seems the "/etc/init.d/apache2 start" method is not loading ruby with the encoding environment variables set properly.

For passenger to do it right we need a wrapper script /usr/local/bin/ruby_utf8:
Quote:

#!/bin/bash
exec /usr/local/bin/ruby -E utf-8:utf-8 "$@"
and then set Passenger to call that script instead of the ruby executable directly:
Quote:

LoadModule passenger_module /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/ext/apache2/mod\
_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.1
PassengerRuby /usr/local/bin/ruby_utf8
It seems that things are running fine now.


All times are GMT -5. The time now is 01:07 AM.