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

发布于 2024-08-31 17:40:09 字数 2267 浏览 10 评论 0原文

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

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

据我所知,至少有 3 种方法可以将 redmine 作为服务运行;他们都不能满足关于这个问题的绩效观点。您可以在以下位置阅读有关它们的信息 如何配置Rails 应用程序(redmine)在 Windows 上作为服务运行?

我都尝试过。设置此类服务的最简单方法是使用 mongrel_service 方法;只需 3 行命令即可完成。但性能明显低于运行该批处理文件...


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

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

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

“[instsrv.exe 路径]\instsrv”Redmine“[srvany.exe 路径]\srvany.exe”

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

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

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

@回声关闭
cd c:\redmine\
mongrel_rails start -a 0.0.0.0 -p 3000 -e 生产

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

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Redmine

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

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

网络启动Redmine

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

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.

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!

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?

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...


Now, I wanna show you my approach:

First suppose we have ruby installed into c:\ruby and we have issued the command gem install mongrel to get the mongrel gem installed into c:\ruby\bin
Also, 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.

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:

"[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"

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

@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:

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.exe into "Value data" section. Then Double-click on "AppParameters" and put /C "C:\redmine\start-redmine.bat" into Value data section.

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

net start 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感谢您的指导!顺便说一句,如果您运行的是 Windows 2008,请使用 mongrel 服务的预发行版本,否则它将无法工作:

gem install mongrel_service --prerelease

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

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:

gem install mongrel_service --prerelease

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文