MCPcopy Create free account
hub / github.com/ElementsProject/lightning / shutdown

Function shutdown

tests/plugins/misc_notifications.py:31–48  ·  view source on GitHub ↗
(plugin, **kwargs)

Source from the content-addressed store, hash-verified

29
30@plugin.subscribe("shutdown")
31def shutdown(plugin, **kwargs):
32
33 # 'shutdown' notification can be called in two ways, from `plugin stop` or from
34 # lightningd's shutdown loop, we test which one by making `getinfo` call
35 try:
36 plugin.rpc.getinfo()
37 plugin.rpc.datastore(key='test', string='Allowed', mode="create-or-append")
38 plugin.log("via plugin stop, datastore success")
39 except RpcError as e:
40 if e.error == {'code': -5, 'message': 'lightningd is shutting down'}:
41 # JSON RPC is disabled by now, but can do logging
42 with pytest.raises(RpcError, match=r'-5.*lightningd is shutting down'):
43 plugin.rpc.datastore(key='test', string='Not allowed', mode="create-or-append")
44 plugin.log("via lightningd shutdown, datastore failed")
45 else:
46 raise
47
48 sys.exit(0)
49
50
51plugin.run()

Callers 2

io_sock_shutdownFunction · 0.85
mainFunction · 0.85

Calls 3

datastoreMethod · 0.80
getinfoMethod · 0.45
logMethod · 0.45

Tested by 1

mainFunction · 0.68