This forum is no longer active. Please post your questions to our new community site

mongrel_rails service::install CPU spikes

Subscribe to mongrel_rails service::install CPU spikes 6 post(s), 2 voice(s)

Avatar r-b-h 5 post(s)

On XP Pro, I can get my rails app to launch using “script/server” but I’m having periodic 100% CPU spikes (ruby.exe) after defining services using the typical method:

mongrel_rails service::install -N “service_name_1” -p “3001” -c “application_directory” —prefix appname

…and mongrel still doesn’t work. Pointing the browser at localhost:3001 yields a page load error.

Defining ~3 mongrels = maxed out CPU.

The same rails app works fine in a non-bitnami stack [Ruby 1.8.6, Rails 2.3.5, same versions of mongrel and mongrel_service].

Does it sound like an app thing? Is mongrel writing a log somewhere (using -B in service::install)? I’m using the postgresql module if that helps.

Avatar Beltrán Rueda Administrator 3,714 post(s)

We found a similar error and it was a problem with ImageMagick. The installer writes a script which configures the environment variables to configure ImageMagick properly for Ruby applications. For example for Redmine the script is in /apps/redmine/script/redmine/scripts/mongrel_rails_envvars.

Try to remove the script if this exists and reinstall the service. Also if you do not need ImageMagick you can try to remove the RMagick gem and the ImageMagick folder in the installation directory. I hope it helps.

Avatar r-b-h 5 post(s)

Unfortunately, ImageMagick/rmagick does not seem to be the cause. Removing the gem and all references in the setenv script didn’t make a difference. The log/mongrel_debug (service::install -B option) doesn’t reveal anything useful either.

I get the same CPU spikes on a second PC (also XP Pro), so it does seem specific to the rubystack. The spikes are coming from ruby.exe rather than mongrel. I’m going to compare my working stack (with Ruby 1.8.6) with Bitnami’s 1.8.7 to see if I can narrow things down.

Any ideas on what 1.8.7 might have changed regarding mongrel?
Since Thin relies on the mongrel parser under the hood, is there any use trying to use Thin as my web server?
Unfortunately, this is a Windows-only project :(

Avatar r-b-h 5 post(s)

…couldn’t get mongrel’s services to work, but Thin is working great. I’m giving up on mongrel’s service::install for now, but will post a solution if I find one.

Avatar r-b-h 5 post(s)

Just following up. Unfortunately, running Thin as a service on Windows is not supported. Grrr. After giving up on win32-service and other schemes, I eventually found a hack that seems to work.

The idea is to start Thin with all its required paths under the SYSTEM account so that it persists past a user log out. This is accomplished by creating a service that launches a cmd with all the required args. The service fails and is deleted, but the ruby.exe process remains. The process can be ungracefully killed later by an autoit script. Use the RunOnce reg key to launch at boot. Not pretty, but it works.

1. START Thin running under the SYSTEM account using a .bat file like this:

@echo off
sc create cloaker binpath= “cmd /K set RUBYOPT=rubygems & set Path=c:\adir\ruby\bin;c:\adir\postgresql\bin;%Path% & cd c:\adir\lc_server\rails_app & thin start”
sc start cloaker
sc delete cloaker

2. STOP Thin (the ruby.exe spawned by Thin actually) by compling an .exe using AutoIT containing this:

$PID = ProcessExists(“ruby.exe”)
If $PID Then ProcessClose($PID)

Avatar Beltrán Rueda Administrator 3,714 post(s)

Thanks for posting the solution. I’m sure that this would be very helpful for other BitNami RubyStack users.

Another solution is to use a Windows Service Wrapper