Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
586 views
in Technique[技术] by (71.8m points)

how to configure a rails app (redmine) to run as a service on windows?

I'm using redmine as a ticket manager, and I'd like to configure it to be run automatically when windows starts up.

How can I configure it to be run as a service?

--

Just asked the question to document it, I hope somebody may find it useful...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

1. using webrick:

ref: http://www.redmine.org/boards/1/topics/4123

  • Download and install the Windows NT Resource Kit from http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

  • Create the service by running this command:

    pathINSTSRV.EXE your_service_name pathSRVANY.EXE
    

    in my case path is:

    "C:Program FilesWindows NT Resource KitINSTSRV.EXE" redmine_webrick "C:Program FilesWindows NT Resource KitSRVANY.EXE"
    

    could be also C:Program FilesWindows Resource KitsTools.

  • Run regedit (Start -> Run -> regedit)

    • Add the following registry key if it's not already there:

      HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesyour_service_name

    • Right click on this registry key and select New -> Key. Name it Parameters.

    • Add two values to the Parameters key. Right click on the parameters key, New -> String Value. Name it Application. Now create another one named AppParameters. Give them the following values:

      • Application: PathToRuby.exe, eg. C: ubyinRuby.exe
      • AppParameters: C:RUBYAPPscriptserver -e production, where RUBYAPP is the directory that contains the redmine website.

      Example: C: edminescriptserver -p 2000 -e production (-p indicates the port webrick will be listening to, and -e the environment used)

Now you can go to Administrative Tools -> Services. There you can start your service (the one with name your_service_name) and test whether or not it is working properly. It should be noted that the service will be marked as started prior to WEBrick finishing its boot procedure. You should give it 1min or so before trying to hit the service to verify that it is working correctly.

2. using mongrel:

ref: http://mongrel.rubyforge.org/wiki ref: http://mongrel.rubyforge.org/wiki/Win32

first install mongrel and mongrel_service gem

gem install mongrel

gem install mongrel_service

then create the service

mongrel_rails service::install -N redmine_mongrel -c c:
edmine -p 3000 -e production

3. using thin:

References:

Instructions:

  1. First install thin (you'll need to install rack gem, if not already installed)

    gem install rack     
    gem install thin
    
  2. Follow the same steps indicated for webrick, but add another value named "AppDirectory". This is needed in order to avoid using c: ubyinhin.bat If I just pointed to the bat file, I couldn't stop the service.

    In HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices edmine_thinParameters add the following keys:

    Application: c: ubyin uby.exe

    AppDirectory: c: edmine

    AppParameters: c: ubyinhin start -p 4000 -e production

------------------------------------------------------------------------------------------

You can control any of your service with the following commands:

net start redmine_xxx

net stop redmine_xxx

sc config redmine_xxx start= auto

sc config redmine_xxx start= auto dependency= MySql

sc delete redmine_xxx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...