mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
utils: make subd_pid return the *last* pid, in case we restarted daemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -472,8 +472,13 @@ class LightningNode(object):
|
|||||||
|
|
||||||
def subd_pid(self, subd):
|
def subd_pid(self, subd):
|
||||||
"""Get the process id of the given subdaemon, eg channeld or gossipd"""
|
"""Get the process id of the given subdaemon, eg channeld or gossipd"""
|
||||||
pidline = self.daemon.is_in_log('lightning_{}.*: pid [0-9]*,'.format(subd))
|
ex = re.compile(r'lightning_{}.*: pid ([0-9]*),'.format(subd))
|
||||||
return re.search(r'pid ([0-9]*),', pidline).group(1)
|
# Make sure we get latest one if it's restarted!
|
||||||
|
for l in reversed(self.daemon.logs):
|
||||||
|
group = ex.search(l)
|
||||||
|
if group:
|
||||||
|
return group.group(1)
|
||||||
|
raise ValueError("No daemon {} found".format(subd))
|
||||||
|
|
||||||
def is_channel_active(self, chanid):
|
def is_channel_active(self, chanid):
|
||||||
channels = self.rpc.listchannels()['channels']
|
channels = self.rpc.listchannels()['channels']
|
||||||
|
|||||||
Reference in New Issue
Block a user