Mongrel as service....odd

I have an odd ( at least for me ) problem with Mongrel running as
service.
Im trying to deploy RoR on a Win2003 server using Mongrel as service
and isapi rewriter for IIS.
When i run mongrel from shell (ruby script/server -p 4000) i can use
my application with no problem of any sort.
When i use mongrel running as service i get a “invalid argument” error
and when i hit the refresh button the controller works fine.
Is there any difference in mongrel running in shell mode or service
mode?

Another question: is there any HowTo for dummies on how to install and
deploy RoR on a fresh linux based server?

Thanks in advance.

On 2/20/07, Fausto [email protected] wrote:

mode?

Fausto, in the future will be really helpful if you provide versions
of the gems (mongrel & rails) you’re using.

In the past, mongrel_service (0.1.0) used to duplicate mongrel_rails
code to implement as service. Since latest release (0.3.1), that is
replaced with original mongrel_rails code (totally DRY).

My suggestions:

  1. Since you said you tested your application with webrick, I’ll try
    doing it with mongrel_rails

cd c:\path\to\my\app
mongrel_rails start -p 4000

Check if it works or not. (browse to your app URL directly
http://localhost:4000/).

  1. If that worked, now perform the same with mongrel_service ‘console’
    functionality:

mongrel_service console single -c “c:\path\to\my\app” -p 4000

Please note that: quotes for path are required if spaces to folders
are used. console and single parameter are needed: they inform
mongrel_service that you will simulate the service and single is the
one ruby-process service bundled into the executable.

  1. If all these things worked, that indicates something is wrong with
    the command line of the service itself (called Image Path).

Check the Services console from the Administrative Tools (or
Start->Run… services.msc). Look for your service name and double
click on it.

Verify the command line (Executable Path) looks something like this:

C:\Ruby\bin\mongrel_service.exe single -c “c:\path\to\my\app” -p 4000

IMPORTANT NOTE: since you say you’re using IIS rewrite, I’ll suggest
you check these rules in case all the previous instructions worked.

Also, you didn’t indicate “production” environment, please check your
development database is set in config/database.yml and you’re sure to
run it that way.

Another question: is there any HowTo for dummies on how to install and
deploy RoR on a fresh linux based server?

Not my field of action :slight_smile:


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

First of all thanks for your reply,
the versions im using are:

Ruby 1.8.5
RubyGem 0.9.0
Rails 1.2.1
Mongrel_Service 0.3.1
Mongrel 1.0.1

I tryed as you suggested and when i run mongrel via command line
mongrel_rails start -p 4000 no problem, running the server version via
console took me to the problem as i copy pasted as follows:

Errno::EINVAL in Contatti#lista
Showing app/views/contatti/lista.rhtml where line #16 raised:

Invalid argument

Any hints?

Thanks

<%= link_to_image("delete.gif", {:controller => 'contatti', :action => 'cancella', :id => contatti}, :confirm => 'Eliminare?', :method => :post, :border=>0) %>

line 16

Here it is the model:

class Contatti < ActiveRecord::Base

file_column :image

belongs_to :“collega”,
:class_name => “Referenti”,
:foreign_key => “referente_id”
belongs_to :“collega2”,
:class_name => “Professioni”,
:foreign_key => “professione_id”
belongs_to :ruolo
belongs_to :quartieri

validates_presence_of :nome, :message => “, Specificare il nome”
validates_presence_of :cognome, :message => “, Specificare il cognome”
validates_uniqueness_of :cognome, :scope => [:cognome, :nome]

validates_associated :collega
end

On 2/21/07, Fausto [email protected] wrote:

class Contatti < ActiveRecord::Base
belongs_to :quartieri

validates_presence_of :nome, :message => “, Specificare il nome”
validates_presence_of :cognome, :message => “, Specificare il cognome”
validates_uniqueness_of :cognome, :scope => [:cognome, :nome]

validates_associated :collega
end

You have a backtrace? since you’re showing me “contatti” in the view,
that means you’re getting contatti = Contatti.find(…) somewhere in
your controller…

Also check tabs and whitespaces since .rhtml (erb) is a bitch parsing
them


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

On 2/20/07, Fausto [email protected] wrote:

I tryed as you suggested and when i run mongrel via command line
mongrel_rails start -p 4000 no problem, running the server version via
console took me to the problem as i copy pasted as follows:

so mongrel_rails start worked when you tried access that page, but the
console service didn’t?

What contains app/views/contatti/lista.rhtml where line #16 ?


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

The Contatti class is properly defined in the model since i can access
it via both console and browser running mongrel not as service.
Do you suggest that the whitespace policy is different from the
service and non service version of mongrel?

Thanks

On 2/24/07, Fausto [email protected] wrote:

The Contatti class is properly defined in the model since i can access
it via both console and browser running mongrel not as service.
Do you suggest that the whitespace policy is different from the
service and non service version of mongrel?

Since services execute with a user account other than your (actually,
the run using LocalService account). They cannot access a lot of
things, these could be: directories, networked drives, etc.

Often these problems are related to permissions. I file marked just
for you will fail tried to access under a service, but this isn’t the
case.

Without the backtrace, I cannot help you deep into the problem, since
I cannot recreate here these conditions.

Also, the command line used to start the service is very important, if
you could access service manager (Start->Run…->services.msc) and
copy the Executable Path shown under your services properties (also
the User account used to run your service).

Regards,


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

Hi.

I too am having the same symptoms:

Backtrace:
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/deprecation.rb:12:in
write' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/deprecation.rb:12:in puts’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/deprecation.rb:12
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/deprecation.rb:23:in
call' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/deprecation.rb:23:in warn’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_view/helpers/url_helper.rb:331:in
convert_options_to_javascript!' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_view/helpers/url_helper.rb:69:in link_to’
#{RAILS_ROOT}/app/views/users/list.rhtml:19:in
_run_rhtml_47app47views47users47list46rhtml' #{RAILS_ROOT}/app/views/users/list.rhtml:8:in each’
#{RAILS_ROOT}/app/views/users/list.rhtml:8:in
`_run_rhtml_47app47views47users47list46rhtml’

Please ask if you want the full trace, since it’s more space to waste on
the thread.

The services are: “c:/ruby/bin/mongrel_service.exe” single -e production
-p 4001 -a 0.0.0.0 -l “log/mongrel.log” -P “log/mongrel.pid” -c
“C:/boxback” -t 0 -r “public” -n 1024

C:/boxback is my application root.

A precise explanation of how things happen is: Webrick OR mongrel as a
non-service, everything’s fine.
With mongrel as a service under lighttpd proxied to IIS with ISAPI
Rewrite and using the Reverse Proxy plugin, when I am -linked- by a
redirect from a create/edit/destroy scaffolding, I get the crash.

More relevant info:
The same happens if I use paginate or @regions = Region.find(:all)

The region file text is:
<% for region in @regions %>

<% for column in Region.content_columns %> <% if column.name == "logo_url" %>

<% end %> <%= simple_format region.send(column.name) %> <% end %> <%= link_to 'Show', :action => 'show', :id => region %> <%= link_to 'Edit', :action => 'edit', :id => region %> <%= link_to 'Destroy', { :action => 'destroy', :id => region }, :confirm => 'Are you sure?', :post => true %> -------ERROR POINTS TO THIS BLANK LINE HERE------- <% end %>

Finally, please note that this application was heavily tested and torn
apart by a small QA group before the migration into
IIS/lighttpd/mongrel. I haven’t a clue what’s wrong.

Luis L. wrote:

On 2/24/07, Fausto [email protected] wrote:

The Contatti class is properly defined in the model since i can access
it via both console and browser running mongrel not as service.
Do you suggest that the whitespace policy is different from the
service and non service version of mongrel?

Since services execute with a user account other than your (actually,
the run using LocalService account). They cannot access a lot of
things, these could be: directories, networked drives, etc.

Often these problems are related to permissions. I file marked just
for you will fail tried to access under a service, but this isn’t the
case.

Without the backtrace, I cannot help you deep into the problem, since
I cannot recreate here these conditions.

Also, the command line used to start the service is very important, if
you could access service manager (Start->Run…->services.msc) and
copy the Executable Path shown under your services properties (also
the User account used to run your service).

Regards,


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

Actually a correction to the above statement and a partial solution.

I hadn’t rebooted all my services on exactly one test I did, so this is
the truth of it:

When I use the paginate command in the controller, I get the error
-EVERY- time I create/edit/delete. It worked fine under heavy testing
before the migration.
When I replace it with @region = Regions.find(:all) and -really- reboot
all my mongrel services, it works perfectly.

It seems either SQL Server, Mongrel, ISAPI Rewrite, or the Reverse proxy
screws with some of the underlying code in paginate…I have no clue
why, but most of my problems were resolved by taking pagination out of
my app.

I really like pagination, though…suggestions appreciated.

On 2/26/07, C.jay Martin [email protected] wrote:

Hi.

I too am having the same symptoms:

Mmm, not the same, let me ask you a few things:

  • What database backend are you using?
  • Since the backend require native bindings (and also some dll). Are
    these dlls (sqlite3.dll or libmysql.dll) available system wide? (try
    putting them into windows\system32).
  • if plain mongrel_rails start … works, then you could try:

mongrel_service console single “all the parameters you use with your
service”:

mongrel_service console single -e production -p 4001 -a 0.0.0.0 -l
“log/mongrel.log” -P “log/mongrel.pid” -c “C:/boxback” -t 0 -r
“public” -n 1024

And see if the application works or report errors.

  • In case it works, now you need to get if your environment (and the
    permissions) are good to run the service.

Please follow the instructions I posted to mongrel-users about similar
problems:

http://rubyforge.org/pipermail/mongrel-users/2007-February/003004.html

Using psexec -l cmd.exe you get a restricted console, try running
mongrel_rails in it and check the console for errors.

Finally, please note that this application was heavily tested and torn
apart by a small QA group before the migration into
IIS/lighttpd/mongrel. I haven’t a clue what’s wrong.

Often is not a problem of test, but permissions of NTFS filesystem or
bugs in the Ruby VM and implementation under windows, who will guess
that?

Anyway, a lot of these problems could be solved, like the one on the
list I make references previously.

Hope could get a solution for the “missing log” of mongrel_service in
the following days.


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

On 2/26/07, C.jay Martin [email protected] wrote:

all my mongrel services, it works perfectly.

AFAIK, mongrel didn’t mess with Rails, but there exist lot of cases
that thigns mess up… :stuck_out_tongue:

It seems either SQL Server, Mongrel, ISAPI Rewrite, or the Reverse proxy
screws with some of the underlying code in paginate…I have no clue
why, but most of my problems were resolved by taking pagination out of
my app.

I really like pagination, though…suggestions appreciated.

Will Paginate?

http://errtheblog.com/post/929


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

On 2/26/07, C.jay Martin [email protected] wrote:

-not- that, then I’ll still be stuck at square one.

Ok, post you progress on this subject or contact me off the list in
any case. Maybe you could provide more inside information and I could
recreate the scenario here to get into the issue.

Regards,


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

Looking up, I’m still pretty sure it’s the same problem, at least to the
root. It’s the exact same error, and more specifically, a refresh works
just fine.

  1. The database backend is SQL Server. This is required by the IT dept
    here. The bindings are system-wide.

  2. I tried adding “console” before single, it didn’t do anything
    helpful.

  3. I tried psexec -l cmd.exe and running mongrel_rails. It worked
    perfectly and showed no errors.

RE: Permissions: I gave the folder full permissions for all users, and
it didn’t help.

Worst of all, the error seems to be “sometimes” now that I disabled
pagination. I -think- it might be a login-limit to the scheduler user
on the database. I’m communicating with the DB Admin regarding that
now. If it -is- that, the error could use to be more clear. If it’s
-not- that, then I’ll still be stuck at square one.

Luis L. wrote:

On 2/26/07, C.jay Martin [email protected] wrote:

Hi.

I too am having the same symptoms:

Mmm, not the same, let me ask you a few things:

  • What database backend are you using?
  • Since the backend require native bindings (and also some dll). Are
    these dlls (sqlite3.dll or libmysql.dll) available system wide? (try
    putting them into windows\system32).
  • if plain mongrel_rails start … works, then you could try:

mongrel_service console single “all the parameters you use with your
service”:

mongrel_service console single -e production -p 4001 -a 0.0.0.0 -l
“log/mongrel.log” -P “log/mongrel.pid” -c “C:/boxback” -t 0 -r
“public” -n 1024

And see if the application works or report errors.

  • In case it works, now you need to get if your environment (and the
    permissions) are good to run the service.

Please follow the instructions I posted to mongrel-users about similar
problems:

http://rubyforge.org/pipermail/mongrel-users/2007-February/003004.html

Using psexec -l cmd.exe you get a restricted console, try running
mongrel_rails in it and check the console for errors.

Finally, please note that this application was heavily tested and torn
apart by a small QA group before the migration into
IIS/lighttpd/mongrel. I haven’t a clue what’s wrong.

Often is not a problem of test, but permissions of NTFS filesystem or
bugs in the Ruby VM and implementation under windows, who will guess
that?

Anyway, a lot of these problems could be solved, like the one on the
list I make references previously.

Hope could get a solution for the “missing log” of mongrel_service in
the following days.


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

Garth Smedley wrote:

Please continue to post progress with this issue, we have something
similar with a page that works fine under WEBrick but has the same error
once in a while under IIS/mongrel.

I’m still awaiting information from the DBA. He doesn’t seem to be in
today. Once I took out pagination, and the other developer stopped
testing it with me, the error counts dropped to about 1 in 7 or 1 in 8,
with me having to push it with simultaneous connections. Either
something is drastically wrong with mongrel’s concurrency capabilities,
or something’s up with SQL Server. At this point, I’m pretty convinced
there’s nothing in my code or NTFS permissions doing this.

Please continue to post progress with this issue, we have something
similar with a page that works fine under WEBrick but has the same error
once in a while under IIS/mongrel.

We just tried removing IIS & isapi rewrite and haven’t been able to
reproduce the problem since. This makes me wonder if it isn’t some odd
interaction between IIS and Mongrel.

C.jay Martin wrote:

Garth Smedley wrote:

Please continue to post progress with this issue, we have something
similar with a page that works fine under WEBrick but has the same error
once in a while under IIS/mongrel.

I’m still awaiting information from the DBA. He doesn’t seem to be in
today. Once I took out pagination, and the other developer stopped
testing it with me, the error counts dropped to about 1 in 7 or 1 in 8,
with me having to push it with simultaneous connections. Either
something is drastically wrong with mongrel’s concurrency capabilities,
or something’s up with SQL Server. At this point, I’m pretty convinced
there’s nothing in my code or NTFS permissions doing this.

NTFS Permissions update:

Tossed the whole thing onto a test box, gave ruby, my app, mongrel, etc
full user permissions. Still seems to happen.

On 2/26/07, C.jay Martin [email protected] wrote:

with me having to push it with simultaneous connections. Either
something is drastically wrong with mongrel’s concurrency capabilities,
or something’s up with SQL Server. At this point, I’m pretty convinced
there’s nothing in my code or NTFS permissions doing this.

NTFS Permissions update:

Tossed the whole thing onto a test box, gave ruby, my app, mongrel, etc
full user permissions. Still seems to happen.

You still use the SQL Server as backend, right?

Could you try a clean rails app as service? put some test controller
(like hello world action).

If that don’t fail, is related to our SQL Server connection that
timeout and raise some issues (randomly it seems).


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

Can’t totally rule out Mongrel routing, because the test was so simple
and I was unable to enforce two simultaneous attempts, but the hello
program, loaded on over 20 panes simultaneously, had zero errors…

Second-check. I did the same exact thing with the login screen for the
real program (it doesn’t link to the database…that’s -IT- for
differences) and not one error. It has to be DB related.

I think all that leaves is the DB, Rails’ link to the database, or
Mongrel’s treatment of the processes in regards to the DB. It’s
definitely related to the DB though.

Luis L. wrote:

On 2/26/07, C.jay Martin [email protected] wrote:

with me having to push it with simultaneous connections. Either
something is drastically wrong with mongrel’s concurrency capabilities,
or something’s up with SQL Server. At this point, I’m pretty convinced
there’s nothing in my code or NTFS permissions doing this.

NTFS Permissions update:

Tossed the whole thing onto a test box, gave ruby, my app, mongrel, etc
full user permissions. Still seems to happen.

You still use the SQL Server as backend, right?

Could you try a clean rails app as service? put some test controller
(like hello world action).

If that don’t fail, is related to our SQL Server connection that
timeout and raise some issues (randomly it seems).


Luis L.
Multimedia systems

Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi