欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

将RedMine安装为Windows服务,开机自动运行 WindowsRubyMySQLRailsXP 

程序员文章站 2022-03-02 22:51:56
...

前段时间用的RedMine,Ruby on Rails写的,通过命令行ruby命令启动,不太方便。因为当系统自动更新重启之后,所有用户就成了注销状态,用户态下执行的命令行进程自然也就没了。
RedMine现在在我们组俨然成了最重要的工具,开机不能自动启动可不行。

Ruby提供一个安装Ruby程序为服务的包:mongrel_service。安装其实很简单,只要命令行下运行gem:

 

gem install mongrel_service

过程中安装一些必须的其他包。

然后将RedMine使用mongrel_service安装成Windows服务:

 

mongrel_rails service::install -N RedMine -c D:\WebRoot -p 80 -e production

这里,我指定服务名为RedMine,我的RedMine在D:\WebRoot,你的要修改,注意指向truck的根目录。监听80端口。

然后修改启动方式为自动启动,并添加MySQL服务为其依赖服务(如果你的MySQL服务器不是本机就不用麻烦了):

 

sc config RedMine start= auto depend= MySQL
 

注意,执行sc config系列指令,服务必须是未启动的才行,否则会出错。

将来如果想去掉这个服务,只要执行:

 

mongrel_rails service::remove -N RedMine

也可以使用:sc delete RedMine 删除服务。


注:以上方法只适合于xp系统。


针对于server2003系统,需要使用下述办法:

转自:http://www.redmine.org/boards/1/topics/4123

 

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

It should be noted that this is not added to your PATH so you will always need to specify absolute paths when running these commands. To add the registry entry for redmine we do:

path\INSTSRV.EXE My Service path\SRVANY.EXE

In my case it looked like this:

"C:\Program Files\Windows NT Resource Kit\INSTSRV.EXE" Redmine "C:\Program Files\Windows NT Resource Kit\SRVANY.EXE"

Then add the following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Redmine

Now go to Start -> Run -> regedit. Right click on the registry key and select New -> Key. Name it "Parameters" without the quotes.

Now we need to 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:

For Application:

C:\ruby\bin\Ruby.exe

For AppParameters:

C:\RUBYAPP\script\server -p 3000 -e production

注: -p 3000表示侦听3000端口。
 

Where RUBYAPP is the directory that contains the redmine website.

Now you can go to Administrative Tools -> Services. There you can start the Redmine service 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.

I hope this helps someone. Good luck.

 

安装Mysql数据库依赖方法不变,即:

sc config Redmine depend= MySQL