如何配置 Rails 应用程序(redmine)在 Windows 上作为服务运行? [英] how to configure a rails app (redmine) to run as a service on windows?

查看:87
本文介绍了如何配置 Rails 应用程序(redmine)在 Windows 上作为服务运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 redmine 作为工单管理器,我想将其配置为在 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...

推荐答案

1.使用 webrick:

参考:http://www.redmine.org/boards/1/topics/4123

通过运行以下命令创建服务:

Create the service by running this command:

path\INSTSRV.EXE your_service_name path\SRVANY.EXE

在我的情况下 path 是:

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

也可以是 C:\Program Files\Windows Resource Kits\Tools\.

运行 regedit(开始 -> 运行 -> regedit)

Run regedit (Start -> Run -> regedit)

  • 添加以下注册表项(如果尚不存在):

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

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\your_service_name

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\your_service_name

右键单击此注册表项并选择新建 -> 项.将其命名为 Parameters.

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

Parameters 键添加两个值.右键单击参数键,新建 -> 字符串值.将其命名为 Application.现在创建另一个名为 AppParameters.给他们以下值:

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:

  • 应用程序:PathToRuby.exe,例如.C:\ruby\bin\Ruby.exe
  • AppParameters:C:\RUBYAPP\script\server -e production,其中RUBYAPP是包含redmine网站的目录.
  • Application: PathToRuby.exe, eg. C:\ruby\bin\Ruby.exe
  • AppParameters: C:\RUBYAPP\script\server -e production, where RUBYAPP is the directory that contains the redmine website.

示例:C:\redmine\script\server -p 2000 -e production(-p 表示 webrick 监听的端口,-e 使用的环境)

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

现在您可以转到管理工具 -> 服务.您可以在那里启动您的服务(名为 your_service_name 的服务)并测试它是否正常工作.应该注意的是,在 WEBrick 完成其启动过程之前,该服务将被标记为已启动.在尝试访问服务以验证它是否正常工作之前,您应该给它 1 分钟左右的时间.

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.使用杂种:

参考:http://mongrel.rubyforge.org/wiki参考:http://mongrel.rubyforge.org/wiki/Win32

首先安装 mongrel 和 mongrel_service gem

first install mongrel and mongrel_service gem

gem install mongrel

gem install mongrel_service

然后创建服务

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

3.使用瘦:

参考资料:

说明:

  1. 首先安装thin(你需要安装rack gem,如果还没有已安装)

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

gem install rack     
gem install thin

  • 按照为 webrick 指示的相同步骤进行操作,但添加另一个名为AppDirectory"的值.这是需要的,以避免使用 c:\ruby\bin\thin.bat 如果我只是指向 bat 文件,我无法停止服务.

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

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\redmine_thin\Parameters中添加以下键:

    应用程序:c:\ruby\bin\ruby.exe

    Application: c:\ruby\bin\ruby.exe

    应用程序目录:c:\redmine

    AppDirectory: c:\redmine

    应用参数:c:\ruby\bin\thin start -p 4000 -e production

    AppParameters: c:\ruby\bin\thin start -p 4000 -e production

  • --------------------------------------------------------------------------------------------

    您可以使用以下命令控制您的任何服务:

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

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

    net start redmine_xxx

    net start redmine_xxx

    net stop redmine_xxx

    net stop redmine_xxx

    sc 配置 redmine_xxx start= auto

    sc config redmine_xxx start= auto

    sc config redmine_xxx start= auto dependency= MySql

    sc config redmine_xxx start= auto dependency= MySql

    sc 删除 redmine_xxx

    sc delete redmine_xxx

    这篇关于如何配置 Rails 应用程序(redmine)在 Windows 上作为服务运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆