Release v0.4.8: wamp connection recovery updated; iotronic.conf updated; new connectivity info added at login.

Change-Id: Ib4d6d03f1a23283f4ab6ac0cbd0b8f0d40f581a4
This commit is contained in:
Nicola Peditto 2019-03-07 09:29:03 +01:00
parent 6c80eab762
commit 80aa81ac4b
3 changed files with 38 additions and 26 deletions

View File

@ -3,7 +3,7 @@ lightningrod_home = /var/lib/iotronic
skip_cert_verify = True
debug = True
log_file = /var/log/iotronic/lightning-rod.log
connection_timer = 10
connection_timer = 30
alive_timer = 600
rpc_alive_timer = 3

View File

@ -82,27 +82,37 @@ def destroyWampSocket():
print(proc_msg)
LOG.info(proc_msg)
wamp_conn_set = False
for socks in conn_list:
# print(socks.raddr, socks.fd)
if socks.raddr != ():
# print(socks.raddr.port, socks.fd)
socks_msg = "FD selected: " + str(socks.fd) \
+ " [port " + str(socks.raddr.port) + "]"
if socks.raddr.port == 8181:
socks_msg = "FD selected: " + str(socks.fd) \
+ " [port " + str(socks.raddr.port) + "]"
print(socks_msg)
LOG.info(socks_msg)
print(socks_msg)
LOG.info(socks_msg)
ws_fd = socks.fd
first = b"call ((void(*)()) shutdown)("
fd = str(ws_fd).encode('ascii')
last = b"u,0)\nquit\ny"
commands = b"%s%s%s" % (first, fd, last)
process.communicate(input=commands)[0]
ws_fd = socks.fd
first = b"call ((void(*)()) shutdown)("
fd = str(ws_fd).encode('ascii')
last = b"u,0)\nquit\ny"
commands = b"%s%s%s" % (first, fd, last)
process.communicate(input=commands)[0]
msg = "Websocket-Zombie closed! Restoring..."
LOG.warning(msg)
print(msg)
break
msg = "Websocket-Zombie closed! Restoring..."
LOG.warning(msg)
print(msg)
# WAMP connection found!
wamp_conn_set = True
# LOG.info("WAMP CONNECTION FOUND")
if wamp_conn_set == False:
LOG.warning("WAMP CONNECTION NOT FOUND: LR restarting...")
# In conn_list there is not the WAMP connection!
LR_restart()
except Exception as e:
LOG.warning("RPC-ALIVE - destroyWampSocket error: " + str(e))
@ -116,6 +126,7 @@ def get_version(package):
def get_socket_info(wport):
lr_mac = "N/A"
try:
@ -135,11 +146,8 @@ def get_socket_info(wport):
for snicaddr in dct[iface]:
if snicaddr.family == 17:
lr_mac = snicaddr.address
print(" - Selected NIC: ", iface,
ip_addr,
lr_mac)
return [iface, ip_addr, lr_mac]
except Exception as e:
LOG.warning("Error getting socket info " + str(e))
lr_mac = "N/A"

View File

@ -78,8 +78,8 @@ CONF.register_opts(lr_opts)
global SESSION
SESSION = None
global lr_mac
lr_mac = None
global lr_cty
lr_cty = {}
global wport
wport = None
@ -318,7 +318,7 @@ async def IotronicLogin(board, session, details):
session=details.session,
info={
"lr_version": str(get_version("iotronic-lightningrod")),
"mac_addr": str(lr_mac)
"connectivity": lr_cty
}
)
@ -399,6 +399,7 @@ def wampConnect(wamp_conf):
wamp_transport = [
{
"url": wamp_transport,
"max_retries": -1,
"serializers": ["json"],
"endpoint": {
"type": "tcp",
@ -434,13 +435,16 @@ def wampConnect(wamp_conf):
"""
global wport
global lr_mac
global lr_cty
sock_bundle = get_socket_info(wport)
if sock_bundle == "N/A":
lr_mac = sock_bundle
lr_cty = sock_bundle
else:
lr_mac = sock_bundle[2]
lr_cty['iface'] = sock_bundle[0]
lr_cty['local_ip'] = sock_bundle[1]
lr_cty['mac'] = sock_bundle[2]
print(" - Selected NIC: " + str(lr_cty))
global connected
connected = True
@ -622,7 +626,7 @@ def wampConnect(wamp_conf):
info={
"lr_version": str(
get_version("iotronic-lightningrod")),
"mac_addr": str(lr_mac)
"connectivity": lr_cty
}
)