fixed an issue cuaisng router to die
- router should not die when an error happens when connecting to HW + install will restart changed network interfaces
This commit is contained in:
@ -12,7 +12,7 @@ from ipaddress import IPv4Interface
|
||||
from configparser import ConfigParser
|
||||
from os.path import join, getmtime, exists
|
||||
|
||||
os.chdir('to_system')
|
||||
os.chdir('/root/aputools/to_system')
|
||||
|
||||
DEL = '__to_delete__'
|
||||
CFGPATH = '/root/aputools/servercfg/%s.cfg'
|
||||
@ -173,6 +173,8 @@ def network(doit):
|
||||
if doit:
|
||||
with open('/etc/sysconfig/network-scripts/ifcfg-%s' % ifname, 'w') as f:
|
||||
f.write('%s\n' % '\n'.join('%s=%s' % kv for kv in content.items()))
|
||||
os.system('ifdown %s' % ifname)
|
||||
os.system('ifup %s' % ifname)
|
||||
else:
|
||||
dirty = 'dirty'
|
||||
print('%s changed:' % ifname)
|
||||
|
@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import socket
|
||||
from select import select
|
||||
from serial import serial_for_url
|
||||
@ -98,7 +99,7 @@ class AcceptHandler:
|
||||
|
||||
:param: port offered port for routing
|
||||
:param: addr where to route
|
||||
:param: iocls the io ahndler class, currently TcpHandler or SerialHandler
|
||||
:param: iocls the io handler class, currently TcpHandler or SerialHandler
|
||||
:param: maxcount the maximal number of concurrent connections. defauls to 1
|
||||
as a side effect, if the destination is a web server, the traffic
|
||||
are serialized (only one connection at a time), which helps for
|
||||
@ -140,8 +141,13 @@ class AcceptHandler:
|
||||
if not self.available:
|
||||
self.pending += 1
|
||||
return
|
||||
try:
|
||||
client, addr = self.socket.accept()
|
||||
handler = self.iocls(client, self)
|
||||
except Exception as e:
|
||||
print('ERROR creating %s(%r)' % (self.iocls.__name__, self.addr))
|
||||
client.close()
|
||||
return
|
||||
self.readers[client.fileno()] = handler.request
|
||||
self.readers[handler.fno] = handler.reply
|
||||
self.available -= 1
|
||||
|
@ -1,9 +1,9 @@
|
||||
[NETWORK]
|
||||
address=00:0d:b9:59:1f:ac
|
||||
enp1s0=dhcp
|
||||
enp2s0=192.168.127.2/24
|
||||
enp3s0=192.168.2.3/24
|
||||
enp4s0=192.168.2.4/24
|
||||
enp2s0=192.168.2.1/24
|
||||
enp3s0=192.168.3.1/24
|
||||
enp4s0=192.168.127.1/24
|
||||
|
||||
[ROUTER]
|
||||
3000=/dev/ttyUSB0
|
||||
|
Reference in New Issue
Block a user