mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
serve: change process title to be more meaningful
Summary: All `hg serve` processes on the server have `hg serve --stdio`, which is not that useful about what it's doing. Change it to include wireproto command, ex. `hg serve (fbsource getfiles client-hostname)` Reviewed By: markbt Differential Revision: D10476292 fbshipit-source-id: ce215800d9422995905357d4d5bd79ca5f1d5337
This commit is contained in:
parent
7009f7f2b0
commit
6fa42dbb08
@ -8,6 +8,8 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
|
||||
from . import encoding, error, hook, util, wireproto
|
||||
@ -119,17 +121,30 @@ class sshserver(wireproto.abstractserverproto):
|
||||
|
||||
def serve_one(self):
|
||||
cmd = self.fin.readline()[:-1]
|
||||
if cmd and cmd in wireproto.commands:
|
||||
rsp = wireproto.dispatch(self.repo, self, cmd)
|
||||
self.handlers[rsp.__class__](self, rsp)
|
||||
elif cmd:
|
||||
impl = getattr(self, "do_" + cmd, None)
|
||||
if impl:
|
||||
r = impl()
|
||||
if r is not None:
|
||||
self.sendresponse(r)
|
||||
if cmd:
|
||||
if util.safehasattr(util, "setprocname"):
|
||||
client = encoding.environ.get("SSH_CLIENT", "").split(" ")[0]
|
||||
# Resolve IP to hostname
|
||||
try:
|
||||
client = socket.gethostbyaddr(client)[0]
|
||||
except (socket.error, IndexError):
|
||||
pass
|
||||
reponame = os.path.basename(self.repo.root)
|
||||
title = "hg serve (%s)" % " ".join(
|
||||
filter(None, [reponame, cmd, client])
|
||||
)
|
||||
util.setprocname(title)
|
||||
if cmd in wireproto.commands:
|
||||
rsp = wireproto.dispatch(self.repo, self, cmd)
|
||||
self.handlers[rsp.__class__](self, rsp)
|
||||
else:
|
||||
self.sendresponse("")
|
||||
impl = getattr(self, "do_" + cmd, None)
|
||||
if impl:
|
||||
r = impl()
|
||||
if r is not None:
|
||||
self.sendresponse(r)
|
||||
else:
|
||||
self.sendresponse("")
|
||||
return cmd != ""
|
||||
|
||||
def _client(self):
|
||||
|
Loading…
Reference in New Issue
Block a user