Differences between revisions 1 and 2
Revision 1 as of 2011-03-22 09:59:19
Size: 3236
Editor: 195
Comment:
Revision 2 as of 2011-03-22 10:03:00
Size: 3142
Editor: 195
Comment:
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
---- {{{
Line 22: Line 22:
Line 24: Line 23:
Line 26: Line 24:
Line 28: Line 25:
Line 30: Line 26:
Line 32: Line 27:
Line 34: Line 28:
Line 36: Line 29:
Line 39: Line 31:
---- }}}
Line 41: Line 34:
----
{{{
Line 43: Line 37:
Line 45: Line 38:

Line 48: Line 39:

Line 51: Line 40:

Line 54: Line 41:

Line 57: Line 42:

Line 60: Line 43:

Line 63: Line 44:

Line 66: Line 45:

Line 69: Line 46:

Line 72: Line 47:

----
}}}
Line 79: Line 53:
---- {{{
Line 81: Line 55:
    <id>Mercurial</id>
    <name>Mercurial</name>
    <description>Mercurial</description>
    <executable>cmd.exe</executable>
    <logpath>c:\nginx\hg\servicelogs</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <startargument>/c "c:\nginx\hg\hg-run start"</startargument>
    <stopargument>/c "c:\nginx\hg\hg-run stop"</stopargument>
</service>
}}}
Line 82: Line 67:
    <id>Mercurial</id>  * Create file hg-run.bat with the following contents:
Line 84: Line 69:
    <name>Mercurial</name> {{{
    @echo off
    if "%1"=="start" (goto :start)
:stop
    taskkill /F /IM hg.exe /T
    goto :end
:start
    "c:\Program Files\Mercurial\hg.exe" serve --address localhost --port 5500 --web-conf c:\nginx\hg\hgweb.conf
:end
}}}
Line 86: Line 80:
    <description>Mercurial</description>  * Create file hgweb.conf with the following contents:
Line 88: Line 82:
    <executable>cmd.exe</executable>

    <logpath>c:\nginx\hg\servicelogs</logpath>

    <logmode>roll</logmode>

    <depend></depend>

    <startargument>/c "c:\nginx\hg\hg-run start"</startargument>

    <stopargument>/c "c:\nginx\hg\hg-run stop"</stopargument>

</service>
----
 * Create file hg-run.bat with the following contents:
----
    @echo off

    if "%1"=="start" (goto :start)

:stop

    taskkill /F /IM hg.exe /T

    goto :end

:start

    "c:\Program Files\Mercurial\hg.exe" serve --address localhost --port 5500 --web-conf c:\nginx\hg\hgweb.conf

:end
----
 * Create file hgweb.conf with the following contents:
----
{{{
Line 123: Line 84:
Line 125: Line 85:
Line 128: Line 87:
[paths]
test = c:\nginx\hg\repository\test
}}}
Line 129: Line 91:
[paths]  * Install services, by starting a command line, cd-ing to c:\nginx and executing the following commands:
Line 131: Line 93:
test = c:\nginx\hg\repository\test
----
 * Install services, by starting a command line, cd-ing to c:\nginx and executing the following commands:
----
{{{
Line 136: Line 95:
c:\nginx> hg-service install
}}}
Line 137: Line 98:
c:\nginx> hg-service install
----

Setting up mercurial with HTTP authentication - Windows

This page describes a complete set of steps for installing hg as a windows service, along with nginx for HTTP proxy authentication. As it is, it is most appropriate for intranet configurations but by adding HTTPS to the mixture, the world is your sea food...

Wish list: - We use mercurial in "hg serve" mode - For HTTP authentication, we use nginx - For nginx/hg windows service integration, we use “Windows Service Wrapper”

1. Download necessary files

2. Configuration

  • Unzip nginx in c:\nginx
  • Copy winsw-1.9-bin.exe in c:\nginx and rename to nginx-service.exe
  • Create file nginx-service.xml with the following contents:

<service>
    <id>nginx</id>
    <name>nginx</name>
    <description>nginx</description>
    <executable>c:\nginx\nginx.exe</executable>
    <logpath>c:\nginx\servicelogs</logpath>
    <logmode>roll</logmode>
    <depend>Mercurial</depend>
    <startargument>-p c:\nginx</startargument>
    <stopargument>-p c:\nginx -s stop</stopargument>
</service>
  • Configure nginx with the following setup (save as c:\nginx\nginx.conf)

    server {
        listen       5000;
        server_name  mis-srv;
        access_log  logs/mis-srv.access.log;
        error_log  logs/mis-srv.error.log;
        location / {
            auth_basic           "Mercurial restricted";
            auth_basic_user_file passwd;
            proxy_pass           http://localhost:5500;
        }
    }
  • Create a password file at conf/passwd, using htpasswd (get from an apache installation) WARNING: On Windows, the passwd file can only contain plaintext passwords

  • Install mercurial binary
  • Create directory for mercurial installation as a service, at c:\nginx\hg
  • Copy winsw-1.9-bin.exe in c:\nginx and rename to hg-service.exe
  • Create file hg-service.xml with the following contents:

<service>
    <id>Mercurial</id>
    <name>Mercurial</name>
    <description>Mercurial</description>
    <executable>cmd.exe</executable>
    <logpath>c:\nginx\hg\servicelogs</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <startargument>/c "c:\nginx\hg\hg-run start"</startargument>
    <stopargument>/c "c:\nginx\hg\hg-run stop"</stopargument>
</service>
  • Create file hg-run.bat with the following contents:

    @echo off
    if "%1"=="start" (goto :start)
:stop
    taskkill /F /IM hg.exe /T
    goto :end
:start
    "c:\Program Files\Mercurial\hg.exe" serve --address localhost --port 5500 --web-conf c:\nginx\hg\hgweb.conf
:end
  • Create file hgweb.conf with the following contents:

[web]
push_ssl = false
allow_push = *

[paths]
test = c:\nginx\hg\repository\test
  • Install services, by starting a command line, cd-ing to c:\nginx and executing the following commands:

c:\nginx> nginx-service install
c:\nginx> hg-service install

And that's all!

HgServeNginxWindows (last edited 2011-10-06 12:17:05 by 212)