hg 作为 Windows 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5179585/
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 16:19:24  来源:igfitidea点击:

hg serve as Windows service

windowsmercurialservice

提问by Adam Schmideg

I'd like to use mercurial on a Windows server. Since I want to pull and push via http, hg serveseems the easiest solution. It works fine, but I have restart it after each reboot, so I need it as a Windows service. Installing it manually with sc create ...didn't work, it created a service that throws an error when I attempt to start it. I found some references to this problem

我想在 Windows 服务器上使用 mercurial。由于我想通过 http 拉取和推送,hg serve似乎是最简单的解决方案。它工作正常,但我每次重启后都重新启动它,所以我需要它作为 Windows 服务。手动安装它sc create ...不起作用,它创建了一个服务,当我尝试启动它时会引发错误。我发现了一些对这个问题的引用

but they are poorly documented if at all. (Of course, I could install a web server and use hgweb, but it seems even more complicated.) Do you have any experience how to set up easily hg serve ... <many args>as a Windows service?

但如果有的话,它们的记录很差。(当然,我也可以装个web服务器,用hgweb,不过好像更复杂。)大家有没有经验如何轻松设置hg serve ... <many args>成Windows服务?

UPDATE: Thanks for the different approaches. We stayed with hg serve, the windows-guy at our company managed to install it as a not-quite-proper service.

更新:感谢不同的方法。我们留在了hg serve,我们公司的 windows-guy 设法将它安装为不太合适的服务。

采纳答案by Jan_V

You should check out Jerremy Skinner his blogposton this subject. He explains how you can host Mercurial repositories on IIS7 and use some nice url-routing. I did it on my machine and it works like a charm. It takes some configuration, but it's worth it.

您应该查看Jerremy Skinner关于此主题的博文。他解释了如何在 IIS7 上托管 Mercurial 存储库并使用一些不错的 url 路由。我在我的机器上做了它,它就像一个魅力。它需要一些配置,但这是值得的。

1 error in his post I noticed was that he's writing about a hgwebdir.cgi, but I couldn't find that one. I did find a hgweb.cgi, so did the copy-pasting with this file.

我注意到他的帖子中的 1 个错误是他在写关于hgwebdir.cgi 的文章,但我找不到那个。我确实找到了一个hgweb.cgi,复制粘贴这个文件也是如此。

回答by sdorra

Or you could use the SCM-Manager

或者你可以使用SCM-Manager

回答by Ruslan Yushchenko

Using a web server such as apache/lighttpd/iis gives a lot of features such as authentication or HTTPS support. But 'hg serve' is a simple and fast solution. Furthermore, 'hg serve' can serve multiple repositories. But hg serve cannot itself be run as a Windows service because it cannot respond to the Windows control commands. So using HgService is a good solution to make 'hg serve' a real Windows service.

使用诸如 apache/lighttpd/iis 之类的 Web 服务器可以提供许多功能,例如身份验证或 HTTPS 支持。但是 'hg serve' 是一个简单而快速的解决方案。此外,'hg serve' 可以为多个存储库提供服务。但是 hg serve 本身不能作为 Windows 服务运行,因为它无法响应 Windows 控制命令。因此,使用HgService是使“hg serve”成为真正的 Windows 服务的一个很好的解决方案。

Here is an example of my configuration. I followed following steps:

这是我的配置示例。我遵循以下步骤:

  • Install TortoiseHG
  • Install HgService
  • Create "C:\Repositories" folder and put needed repos into it.
  • Create "C:\Repositories\hgweb.config" with following contents:
  • 安装 TortoiseHG
  • 安装 HgService
  • 创建“C:\Repositories”文件夹并将所需的存储库放入其中。
  • 使用以下内容创建“C:\Repositories\hgweb.config”:
[paths]
/ = C:\Repositories\*

[web]
style = monoblue
  • Modify HgService.exe.config in C:\Program Files\Mercurial\HgService
  • 修改 C:\Program Files\Mercurial\HgService 中的 HgService.exe.config
<add key="CommandLine" value="hg.exe"/>
<add key="CommandLineArguments" value="serve --prefix=/hg --address 0.0.0.0 --port 80 --web-conf c:\Repositories\hgweb.config -A access.log -E error.log" />
  • Start the service
  • 启动服务

Hope this sequence of action will be helpful to you also.

希望这一系列的动作也能对你有所帮助。

回答by Serafeim

hg serve works fine with NSSM!

hg serve 与NSSM一起工作正常!

回答by alexandrul