Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hg serve as Windows service

I'd like to use mercurial on a Windows server. Since I want to pull and push via http, hg serve seems 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

  • https://bitbucket.org/tortoisehg/stable/issue/1245/configure-hg-serve-to-run-as-a-windows-service-from
  • https://bitbucket.org/andrearicossa/hgservice

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?

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.

like image 264
Adam Schmideg Avatar asked Mar 03 '11 10:03

Adam Schmideg


3 Answers

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.

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:
[paths]
/ = C:\Repositories\*

[web]
style = monoblue
  • Modify HgService.exe.config in C:\Program Files\Mercurial\HgService
<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.

like image 81
Ruslan Yushchenko Avatar answered Sep 21 '22 19:09

Ruslan Yushchenko


Or you could use the SCM-Manager

like image 5
sdorra Avatar answered Sep 24 '22 19:09

sdorra


You should check out Jerremy Skinner his blogpost on 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.

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.

like image 2
Jan_V Avatar answered Sep 24 '22 19:09

Jan_V