A simple start/stop/status wrapper to hg serve
Yann E. MORIN
yann.morin.1998 at anciens.enib.fr
Mon Aug 10 14:45:14 CDT 2009
Hello All!
The attached script, hgserve, is a simple wrapper to easily start and stop
local "hg serve" daemons. It can also list the currently running daemons.
The "hg serve" daemons are bound to the loopback address only, and a
listening port can be specified.
I wrote this script because I needed to locally browse a few repositories
during development, and found it quite cumbersome to manually start
"hg serve" daemons so they went to backgound and be silent, and even more
cumbersome to then stop them when I did no longer need them.
So I came up with this little script, and if it can help someone else,
then all the better! It's quite crude, but it works. :-)
Here's the output of "hgserve help" for more explanations:
--8<--
'hgserve': serves the current Mercurial repository via http
'hgserve' manages running and stopping a Mercurial's 'hg serve'
server for the current repository. The server binds to the loopback
address only, for purely local serving.
'hgserve' can come handy if you want to browse multiple repositories
on your machine, and avoids the hassle of manually starting/stopping
the servers.
Usage:
hgserve [action] [port]
action
Performs the specified action: start, stop, status, or help.
start : starts a server (default)
stop : stops a server
status: lists possibly running servers
help : prints this help
port
Starts a server on that port, or stops the server already running
on that port. Default port is 8000 (hg serve default port).
Examples:
hgserve
hgserve start
starts a server listenning on port 8000
hgserve 8192
hgserve start 8192
starts a server listenning on port 8192
hgserve stop
stops the server listenning on port 8000
hgserve stop 8192
stops the server listenning on port 8192
hgserve status
prints a list of (possible) running servers, with the
port they each are running on, and the repository they
each are serving
--8<--
Regards,
Yann E. MORIN.
PS. There are a few pre-requisites: curl, awk, netstat, ps, grep, printf,
setsid, and a POSIX-compliant shell. But that shall not be a problem
on most setups...
Oh, it's not in Python, but pure shell, sorry! :-]
YEM.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software Designer | \ / CAMPAIGN | ___ |
| --==< ^_^ >==-- `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
`------------------------------^-------^------------------^--------------------'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hgserve
Type: application/x-shellscript
Size: 3932 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial/attachments/20090810/6c023967/attachment.bin
More information about the Mercurial
mailing list