Show More
@@ -2461,10 +2461,7 b' def serve(ui, repo, **opts):' | |||||
2461 | class service: |
|
2461 | class service: | |
2462 | def init(self): |
|
2462 | def init(self): | |
2463 | util.set_signal_handler() |
|
2463 | util.set_signal_handler() | |
2464 | try: |
|
|||
2465 |
|
|
2464 | self.httpd = hgweb.server.create_server(parentui, repo) | |
2466 | except socket.error, inst: |
|
|||
2467 | raise util.Abort(_('cannot start server: ') + inst.args[1]) |
|
|||
2468 |
|
2465 | |||
2469 | if not ui.verbose: return |
|
2466 | if not ui.verbose: return | |
2470 |
|
2467 | |||
@@ -2473,12 +2470,12 b' def serve(ui, repo, **opts):' | |||||
2473 | else: |
|
2470 | else: | |
2474 | prefix = '' |
|
2471 | prefix = '' | |
2475 |
|
2472 | |||
2476 |
|
|
2473 | port = ':%d' % self.httpd.port | |
2477 | ui.status(_('listening at http://%s:%d/%s\n') % |
|
2474 | if port == ':80': | |
2478 | (self.httpd.addr, self.httpd.port, prefix)) |
|
2475 | port = '' | |
2479 | else: |
|
2476 | ||
2480 |
|
|
2477 | ui.status(_('listening at http://%s%s/%s (%s:%d)\n') % | |
2481 |
|
|
2478 | (self.httpd.fqaddr, port, prefix, self.httpd.addr, self.httpd.port)) | |
2482 |
|
2479 | |||
2483 | def run(self): |
|
2480 | def run(self): | |
2484 | self.httpd.serve_forever() |
|
2481 | self.httpd.serve_forever() | |
@@ -3115,8 +3112,8 b' table = {' | |||||
3115 | ('d', 'daemon', None, _('run server in background')), |
|
3112 | ('d', 'daemon', None, _('run server in background')), | |
3116 | ('', 'daemon-pipefds', '', _('used internally by daemon mode')), |
|
3113 | ('', 'daemon-pipefds', '', _('used internally by daemon mode')), | |
3117 | ('E', 'errorlog', '', _('name of error log file to write to')), |
|
3114 | ('E', 'errorlog', '', _('name of error log file to write to')), | |
3118 |
('p', 'port', 0, _('port to |
|
3115 | ('p', 'port', 0, _('port to listen on (default: 8000)')), | |
3119 |
('a', 'address', '', _('address to |
|
3116 | ('a', 'address', '', _('address to listen on (default: all interfaces)')), | |
3120 | ('', 'prefix', '', _('prefix path to serve from (default: server root)')), |
|
3117 | ('', 'prefix', '', _('prefix path to serve from (default: server root)')), | |
3121 | ('n', 'name', '', |
|
3118 | ('n', 'name', '', | |
3122 | _('name to show in web pages (default: working dir)')), |
|
3119 | _('name to show in web pages (default: working dir)')), |
@@ -253,13 +253,6 b' def create_server(ui, repo):' | |||||
253 | return hgwebobj |
|
253 | return hgwebobj | |
254 | self.application = make_handler() |
|
254 | self.application = make_handler() | |
255 |
|
255 | |||
256 | addr = address |
|
|||
257 | if addr in ('', '::'): |
|
|||
258 | addr = socket.gethostname() |
|
|||
259 |
|
||||
260 | self.addr, self.port = addr, port |
|
|||
261 | self.prefix = prefix |
|
|||
262 |
|
||||
263 | if ssl_cert: |
|
256 | if ssl_cert: | |
264 | try: |
|
257 | try: | |
265 | from OpenSSL import SSL |
|
258 | from OpenSSL import SSL | |
@@ -273,6 +266,15 b' def create_server(ui, repo):' | |||||
273 | self.server_bind() |
|
266 | self.server_bind() | |
274 | self.server_activate() |
|
267 | self.server_activate() | |
275 |
|
268 | |||
|
269 | self.addr, self.port = self.socket.getsockname()[0:2] | |||
|
270 | self.prefix = prefix | |||
|
271 | ||||
|
272 | self.fqaddr = socket.getfqdn(address) | |||
|
273 | try: | |||
|
274 | socket.getaddrbyhost(self.fqaddr) | |||
|
275 | except: | |||
|
276 | fqaddr = address | |||
|
277 | ||||
276 | class IPv6HTTPServer(MercurialHTTPServer): |
|
278 | class IPv6HTTPServer(MercurialHTTPServer): | |
277 | address_family = getattr(socket, 'AF_INET6', None) |
|
279 | address_family = getattr(socket, 'AF_INET6', None) | |
278 |
|
280 | |||
@@ -292,4 +294,5 b' def create_server(ui, repo):' | |||||
292 | else: |
|
294 | else: | |
293 | return MercurialHTTPServer((address, port), handler) |
|
295 | return MercurialHTTPServer((address, port), handler) | |
294 | except socket.error, inst: |
|
296 | except socket.error, inst: | |
295 |
raise util.Abort(_(' |
|
297 | raise util.Abort(_("cannot start server at '%s:%d': %s") | |
|
298 | % (address, port, inst.args[1])) |
@@ -9,7 +9,7 b" hg commit -A -d '0 0' -m 1" | |||||
9 | hg --config server.uncompressed=True serve -p $HGPORT -d --pid-file=../hg1.pid |
|
9 | hg --config server.uncompressed=True serve -p $HGPORT -d --pid-file=../hg1.pid | |
10 | hg serve -p $HGPORT1 -d --pid-file=../hg2.pid |
|
10 | hg serve -p $HGPORT1 -d --pid-file=../hg2.pid | |
11 | # Test server address cannot be reused |
|
11 | # Test server address cannot be reused | |
12 |
hg serve -p $HGPORT1 2>&1 | sed -e |
|
12 | hg serve -p $HGPORT1 2>&1 | sed -e "s/abort: cannot start server at ':$HGPORT1':.*/abort: cannot start server at ':$HGPORT1':/" | |
13 | cd .. |
|
13 | cd .. | |
14 | cat hg1.pid hg2.pid >> $DAEMON_PIDS |
|
14 | cat hg1.pid hg2.pid >> $DAEMON_PIDS | |
15 |
|
15 |
@@ -1,5 +1,5 b'' | |||||
1 | adding foo |
|
1 | adding foo | |
2 | abort: cannot start server: |
|
2 | abort: cannot start server at ':20060': | |
3 | % clone via stream |
|
3 | % clone via stream | |
4 | streaming all changes |
|
4 | streaming all changes | |
5 | XXX files to transfer, XXX bytes of data |
|
5 | XXX files to transfer, XXX bytes of data |
@@ -14,33 +14,38 b' if [ -f access.log ]; then' | |||||
14 | fi |
|
14 | fi | |
15 |
|
15 | |||
16 | echo % With -v |
|
16 | echo % With -v | |
17 |
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v |
|
17 | hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v \ | |
|
18 | | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/' | |||
18 | cat hg.pid >> "$DAEMON_PIDS" |
|
19 | cat hg.pid >> "$DAEMON_PIDS" | |
19 | sleep 1 |
|
20 | sleep 1 | |
20 | kill `cat hg.pid` |
|
21 | kill `cat hg.pid` | |
21 | sleep 1 |
|
22 | sleep 1 | |
22 |
|
23 | |||
23 | echo % With --prefix foo |
|
24 | echo % With --prefix foo | |
24 |
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix foo |
|
25 | hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix foo \ | |
|
26 | | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/' | |||
25 | cat hg.pid >> "$DAEMON_PIDS" |
|
27 | cat hg.pid >> "$DAEMON_PIDS" | |
26 | sleep 1 |
|
28 | sleep 1 | |
27 | kill `cat hg.pid` |
|
29 | kill `cat hg.pid` | |
28 | sleep 1 |
|
30 | sleep 1 | |
29 |
|
31 | |||
30 | echo % With --prefix /foo |
|
32 | echo % With --prefix /foo | |
31 |
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix /foo |
|
33 | hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix /foo \ | |
|
34 | | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/' | |||
32 | cat hg.pid >> "$DAEMON_PIDS" |
|
35 | cat hg.pid >> "$DAEMON_PIDS" | |
33 | sleep 1 |
|
36 | sleep 1 | |
34 | kill `cat hg.pid` |
|
37 | kill `cat hg.pid` | |
35 | sleep 1 |
|
38 | sleep 1 | |
36 |
|
39 | |||
37 | echo % With --prefix foo/ |
|
40 | echo % With --prefix foo/ | |
38 |
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix foo/ |
|
41 | hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix foo/ \ | |
|
42 | | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/' | |||
39 | cat hg.pid >> "$DAEMON_PIDS" |
|
43 | cat hg.pid >> "$DAEMON_PIDS" | |
40 | sleep 1 |
|
44 | sleep 1 | |
41 | kill `cat hg.pid` |
|
45 | kill `cat hg.pid` | |
42 | sleep 1 |
|
46 | sleep 1 | |
43 |
|
47 | |||
44 | echo % With --prefix /foo/ |
|
48 | echo % With --prefix /foo/ | |
45 |
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix /foo/ |
|
49 | hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix /foo/ \ | |
|
50 | | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/' | |||
46 | cat hg.pid >> "$DAEMON_PIDS" |
|
51 | cat hg.pid >> "$DAEMON_PIDS" |
@@ -1,12 +1,12 b'' | |||||
1 | % Without -v |
|
1 | % Without -v | |
2 | access log created - .hg/hgrc respected |
|
2 | access log created - .hg/hgrc respected | |
3 | % With -v |
|
3 | % With -v | |
4 | listening at http://localhost/ |
|
4 | listening at http://localhost/ (127.0.0.1) | |
5 | % With --prefix foo |
|
5 | % With --prefix foo | |
6 | listening at http://localhost/foo/ |
|
6 | listening at http://localhost/foo/ (127.0.0.1) | |
7 | % With --prefix /foo |
|
7 | % With --prefix /foo | |
8 | listening at http://localhost/foo/ |
|
8 | listening at http://localhost/foo/ (127.0.0.1) | |
9 | % With --prefix foo/ |
|
9 | % With --prefix foo/ | |
10 | listening at http://localhost/foo/ |
|
10 | listening at http://localhost/foo/ (127.0.0.1) | |
11 | % With --prefix /foo/ |
|
11 | % With --prefix /foo/ | |
12 | listening at http://localhost/foo/ |
|
12 | listening at http://localhost/foo/ (127.0.0.1) |
General Comments 0
You need to be logged in to leave comments.
Login now