## mongrel_service alternative: using thin and srvany

### ... but Windows Server 2008

Unfortunately, to do this on Windows 2008 you need to perform some extra steps. As you can't install the resource kit on Windows Server 2008R2 for some peculiar reason, and at the time of this posting, i have not found a Windows Server 2008 Resource Kit Tools, so i took the following steps:

1. copy the "srvany.exe " from the "Windows Server 2003 Resource Kit Tools " to a suitable location on your Win2008 server (e.g. C:\Windows\System32\ )
2. use "sc " to create a new service that launches "srvany " (e.g. sc create MyService binPath= C:\Windows\System32\srvany.exe DisplayName= "My Custom Service" )
3. using RegEdit create a "Parameters " key for your service as before and fill it with the 3 string values A bit more work, but not too much.

### mongrel-service?

And just today I discovered an update of mongrel_service was announced, so you can still work using mongrel_service instead of using thin and manually creating the service. What you need to do:

• install mongrel service: gem install mongrel_service --prerelease
• create the service as before: mongrel_rails service::install -N myapp -c c:\my\path\to\myapp -p 4000 -e production That is much easier of course.

gamov 2011-03-11 03:35:52 UTC

Hello, I'm struggling to find a way of deploying rails3/ruby192 apps on Windows. Your solution seems excellent but you don't specify the rails version you are using? Another question for you? Is it easy to compile thin on Windows or it's a headache? gem install thin doesn't look very good since it wants to build stuff which is always scary on Windods :D Thanks for your time, Gam

Nathan 2011-03-11 09:50:21 UTC

I used this solution both on ruby 1.8.7 and 1.9.2. Just make sure you get a ruby from the mingw32 platform (hhtp://rubyinstaller.com). If you install the developer kit (http://rubyinstaller.org/add-ons/devkit/) as well, installing a gem like thin will just work (and it will compile on the fly). So it actually is really easy. Good luck!

Marco Matrodonato 2011-03-15 10:28:25 UTC

Hello, i use mongrel_service and mingw32 on production environment built on windows 2008 R2 64bit, it works.

Will 2011-09-14 18:40:43 UTC

Great article, Nathan! Thanks! I was able to get this working with Windows 2008 R2, Ruby 1.9.2 and Rails. Started serving with Webrick and switch to thin. I am also using Application Request Routing via IIS7 to balance/host. (http://www.iis.net/download/ApplicationRequestRouting) gamov, you can also install eventmachine easily by specifying a platform... just have a look at: gem list -r eventmachine ...you should get something like: eventmachine (0.12.10 ruby java x86-mswin32-60 ...) ...the list after the version is a list of available platforms... so: gem install eventmachine --platform=x86-mswin32-60 ...should fix you up. Thins is definitely worth the trouble.

Will 2011-09-14 19:05:49 UTC

UPDATE: I lied. The platform option installs a version of eventmachine linked against the 1.8, not the 1.9... so it works for 1.8 folks not the 1.9. Sorry, for the confusion there.

Nathan 2011-09-15 09:30:46 UTC

Glad the article was useful for you.

Ray Shih 2011-10-02 05:11:45 UTC

Rachid Benkirane 2013-04-21 11:23:27 UTC

Lourdes Van-Koningsloo Higon 2013-10-28 12:52:30 UTC

I have a problem with thin server. I have created a service in windows and load well, but when I put the address in internet and I get an error The Page can't be displayed. If I do rails s -e production from command line is work perfectly. Could you help me?

nathanvda 2013-10-28 13:26:50 UTC

Thank you Lourdes, for another question in the category: "please use your psychic skills to guess my problem". I could help you, with a little more information. Did you create the service as I described it? When the service is starting, do you see the production.log file being made, and if so: do you see any errors? If it is not starting: check the application folder in your service configuration. Do you start the service on port 4000 (as I suggested) and are you checking on port 4000? E.g. <code>http://localhost:4000</code>

Lourdes Van-Koningsloo Higon 2013-10-28 14:57:33 UTC

Hello nathanvda. I have install windows 2008, I create the service as you described it, in port 4000. I create in regedit AppDirectory, Application and AppParameters. AppDirectory= C:\Sites\aplicaciones Application = C:\RailsInstaller\Ruby1.9.3\bin\ruby.exe AppParameters = C:\RailsInstaller\Ruby1.9.3\bin\thin start -p 4000 -e production. Service run correctly without errors. if I put http://localhost:4000 the error is This page can't be display If I run from command line rails s -p 4000 -e production is ok. In production.log I can't see any error. Thanks in advanced. Lourdes

nathanvda 2013-10-28 15:11:16 UTC

My spanish is no good, but the c:\sites\aplicaciones is the rails folder? because it sounds like applications, and it should be the rails root folder. Otherwise I have no clue. Is the error you get a rails error (this page can't be displayed?). If so, the rails server is hit. Maybe proxy settings? Try running <code>thin start -p 4000 -e production</code> from the command line?

Lourdes Van-Koningsloo Higon 2013-10-28 15:26:51 UTC

No, c:\sites\aplicaciones is my aplication. If I try thin start -p 4000 -e production from the command line, it gives me an error: You have alredy activated rack 1.5.2 but your gemfile requiere rack 1.4.5. Using bundle exect you may solve this. Sorry but before I used mongrel_service and I have update rails in a new server and I install rails 3.2.13, and mongrel_service doesn't work. Thanks

nathanvda 2013-10-28 17:22:56 UTC

The mongrel_service will most likely have the same error. Easiest to update rake in your gemfile to the newest version? Or use <code>bundle exec</code>. Nice it is solved.

Lourdes Van-Koningsloo Higon 2013-11-22 08:27:09 UTC

Hello nathanvda, how many services whith thin I can run? I have three ( ports 4000, 40001, 4002), but today I create other (4003), and the the threee frists doesn't work Thanks in advanced. Lourdes

nathanvda 2013-11-22 09:45:31 UTC

There is normally no limitation, except for available memory and database connections (resources). Normally one extra would not be a problem, and even if it was, it would only be a problem for the one extra (if it is a lack of resources that is the cause of your problem). So I think you have another problem :)

Lokendra 2014-01-28 10:33:48 UTC

Got an error 'http://localhost:4000' while using using thin server as a service with Rails 3. My production.log file shows the text "Connecting to database specified by database.yml". Any help would be appreciated. Thanks

nathanvda 2014-01-28 11:22:04 UTC

Hi Lokendra: that is not really an error? :) My guess: have you checked the <code>production</code> entry in your database.yml ? It seems like it is trying to connect and does not find the database? If that does not solve it: check stackoverflow.com and/or ask your question there. You will need to provide a little more background, because you provide very little information here.

Lokendra 2014-01-28 12:46:49 UTC

Hi Nathanvda, Thanks for the quick response. Actually the same database details works when I run thin server from command prompt, but through service I got error. And my database.yml file contains information: production: adapter: sqlserver dsn: DSN_Name # created System DSN mode: odbc database: Database_Name username: sa password: passwd host: 127.0.0.1

nathanvda 2014-01-28 13:15:47 UTC

Do you run thin server from command prompt in production mode? Please note, like I said, that stackoverflow is a better forum for such questions :)

Jenny 2014-05-12 13:42:59 UTC

Hello, I install ruby193, now I want to create windows service for redmine via mongrel service, but when I write the command mongrel_rails service::install -N RedMine -c d:RailsInstaller\sites\redmine(this is the path for redmine) -p 3000 -e production, it shows an error as below: d:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb: 36:in require': 126: The specified module could not be found. - d:/RailsInsta ller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5-x86-mingw32/lib/http11.so (LoadError) from d:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custo m_require.rb:36:in require' from d:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5- x86-mingw32/lib/mongrel.rb:12:in ' from d:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custo m_require.rb:36:in require' from d:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custo m_require.rb:36:in require' from d:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5- x86-mingw32/bin/mongrel_rails:11:in ' from d:/RailsInstaller/Ruby1.9.3/bin/mongrel_rails:23:in load' from d:/RailsInstaller/Ruby1.9.3/bin/mongrel_rails:23:in ' I am new for redmine, ruby, and mongrel, so can anybody help me on this ? Thank you.

nathanvda 2014-05-12 14:11:22 UTC

Can you ask this question on stackoverflow, and post the link here? Please note that mongrel_rails is no longer at this moment, so you better use thin.

Daniel 2015-02-09 23:06:12 UTC

Hi, I realise I'm posting this late but everything is working fine on Windows 7 but when I run the service it runs but no sign of thin server running, i.e. no logs being created. I'm wondering could you give me more info on how to create the String Values, might be doing this wrong. Thanks, Dan

Abhishek Srivastava 2015-12-18 06:16:54 UTC

I am using the same approach and I don't see any logs either. I am trying to debug a issue and have no clue now.

nathanvda 2015-12-18 08:32:17 UTC

My best guess: did you try running <pre>rails s -p 4000 -e production</pre> on the command-line? (as mentioned before).Running a rails app in production is something different: it will connect to a different database entry, and it will pre-load all code, meaning any error (even in unused code) will block starting your rails process.