Howto - 在 mongrel 上运行 Redmine 作为 Windows 上的服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2781795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:25:06  来源:igfitidea点击:

Howto - Running Redmine on mongrel as a service on windows

windowsrubyservicemongrelredmine

提问by Achilles

I use Redmine on Mongrel as a project manager and I use a batch file (start-redmine.bat) to start the redmine in mongrel. There are 2 issues with my setup: 1. I have a running IIS on the server that occupies the HTTP port (80) 2. The start-redmine.bat must be periodically checked to see if it's stopped after a restart that is caused by windows update service.

我在 Mongrel 上使用 Redmine 作为项目经理,并使用批处理文件 (start-redmine.bat) 在 mongrel 中启动 redmine。我的设置有两个问题: 1. 我在服务器上有一个运行的 IIS,它占用了 HTTP 端口 (80) 2. 必须定期检查 start-redmine.bat 以查看它是否在由以下原因引起的重启后停止Windows 更新服务。

for the first issue, I have no choice but running mongrel on a port like 3000 and for the second issue I have to create a windows service that runs automatically in the background when the windows starts; and here comes the trouble!

对于第一个问题,我别无选择,只能在 3000 等端口上运行 mongrel,对于第二个问题,我必须创建一个 Windows 服务,该服务在 Windows 启动时在后台自动运行;麻烦来了!

There are at least 3 ways to run redmine as a service that I'm aware of; none of them can satisfy a performance view on this subject. you may read about them on how to configure a rails app (redmine) to run as a service on windows?

我知道至少有 3 种方法可以将 redmine 作为服务运行;他们中没有一个能满足对这个主题的性能观点。您可能会阅读有关 如何配置 Rails 应用程序(redmine)以在 Windows 上作为服务运行的内容?

I tried them all. The easiest way to setup such a service is using mongrel_service approach; in 3 lines of command you're done. but the performance is significantly lower than running that batch file...

我都试过了。设置此类服务的最简单方法是使用 mongrel_service 方法;在 3 行命令中,您就完成了。但性能明显低于运行该批处理文件......



Now, I wanna show you my approach:

First suppose we have ruby installed into c:\rubyand we have issued the command gem install mongrelto get the mongrel gem installed into c:\ruby\binAlso, suppose we have installed the Redmine into a folder like c:\redmine; and we have ruby's path (i.e. c:\ruby\bin) in our PATH environment variable.

现在,我想向你展示我的方法:

首先假设我们已经将 ruby​​ 安装到c:\ruby并且我们已经发出命令gem install mongrel将 mongrel gem 安装到c:\ruby\bin另外,假设我们已经安装了 Redmine进入像c:\redmine这样的文件夹;我们的 PATH 环境变量中有 ruby​​ 的路径(即c:\ruby\bin)。

Now Download and install the Windows NT Resource Kit Tools from microsoft website. Open the command-line tool that comes with the Resource Kit (from start menu). Use instsrv to install a dummy service called Redmine using the following command:

现在从微软网站下载并安装 Windows NT Resource Kit 工具。打开 Resource Kit 附带的命令行工具(从开始菜单)。使用 instsrv 使用以下命令安装名为 Redmine 的虚拟服务:

"[path-to-instsrv.exe]\instsrv" Redmine "[path-to-srvany.exe]\srvany.exe"

"[path-to-instsrv.exe]\instsrv" Redmine "[path-to-srvany.exe]\srvany.exe"

in my case (which is the default case) it was something like this:

在我的情况下(这是默认情况)它是这样的:

"C:\Program Files\Windows Resource Kits\Tools\instsrv" Redmine "C:\Program Files\Windows Resource Kits\Tools\srvany.exe"

"C:\Program Files\Windows Resource Kits\Tools\instsrv" Redmine "C:\Program Files\Windows Resource Kits\Tools\srvany.exe"

Now create the batch file. Open a notepad and paste these instructions into it and then save it as "c:\redmine\start-redmine.bat"

现在创建批处理文件。打开记事本并将这些说明粘贴到其中,然后将其另存为“ c:\redmine\start-redmine.bat

@echo off
cd c:\redmine\
mongrel_rails start -a 0.0.0.0 -p 3000 -e production

@echo off
cd c:\redmine\
mongrel_rails start -a 0.0.0.0 -p 3000 -e production

Now we need to configure that dummy service we had created before. WATCH OUT WHAT YOU'RE DOING FROM HERE ON, OR YOU MAY CORRUPT YOUR WINDOWS. To configure that service, open windows registry editor (Start -> Run -> regedit) and navigate to this node:

现在我们需要配置我们之前创建的虚拟服务。从现在开始注意你在做什么,否则你可能会损坏你的窗口。要配置该服务,请打开 Windows 注册表编辑器(开始 -> 运行 -> regedit)并导航到此节点:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Redmine

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Redmine

Right-Click on "Redmine" node and using the context menu, create a new key called Parameters(New -> Key) Right-Click on "Parameters" and create a String Value property called Application. Do this again and create another String Value called AppParameters. Now Double-click on "Application" and put cmd.exeinto "Value data" section. Then Double-click on "AppParameters" and put /C "C:\redmine\start-redmine.bat"into Value data section.

右键单击“Redmine”节点并使用上下文菜单,创建一个名为Parameters(New -> Key)的新键。右键单击“Parameters”并创建一个名为Application的 String Value 属性。再次执行此操作并创建另一个名为AppParameters 的字符串值。现在双击“应用程序”并将cmd.exe放入“值数据”部分。然后双击“AppParameters”并将/C“C:\redmine\start-redmine.bat”放入数值数据部分。

We're done! issue this command to run the redmine on mongrel as a service:

我们完成了!发出此命令以将 redmine 作为服务在 mongrel 上运行:

net start Redmine

网络启动Redmine

Edit: If you're gonna use the mail services of Redmine and you have an anti-virus like McAfee, make sure you told the anti-virus to allow ruby send emails or you won't get the mail service working.

编辑:如果您要使用 Redmine 的邮件服务并且您有像 McAfee 这样的防病毒软件,请确保您告诉防病毒软件允许 ruby​​ 发送电子邮件,否则您将无法使用邮件服务。

回答by TruMan1

Thanks for the guide! By the way, if you're running Windows 2008, use the prerelease version of the mongrel service or else it won't work for you:

谢谢指导!顺便说一句,如果您运行的是 Windows 2008,请使用 mongrel 服务的预发布版本,否则它对您不起作用:

gem install mongrel_service --prerelease

gem install mongrel_service --prerelease

http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/1adf2a73c75c2884/38267c06198e282e?show_docid=38267c06198e282e

http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/1adf2a73c75c2884/38267c06198e282e?show_docid=38267c06198e282e