some helps. separate port for tcp

This commit is contained in:
q
2017-12-18 10:12:45 +02:00
parent bbdffb55be
commit 0cae5ec2f7
2 changed files with 23 additions and 9 deletions

View File

@@ -11,3 +11,9 @@ You can send a custom text file with the update, generated with ex. `nando-desc`
Nando clients can query which other clients are online, and what their status is
(whatever you choose to update with the text data)
## Installer
as root, with your own risk:
curl https://bitbucket.org/MoonQ/nando/raw/tip/update.sh | bash -

26
nandod
View File

@@ -13,13 +13,15 @@ def setup_options():
parser=ArgumentParser(description="Alive notifier.")
parser.add_argument("--host",action='store', dest='HOST',default='0.0.0.0',type=str,
help="Bind to address")
help="Bind to address: %(default)s")
parser.add_argument("--port", action='store', dest='PORT', default=13370,type=int,
help="Bind to port")
help="Bind to port: %(default)s")
parser.add_argument("--html-port", action='store', dest='WEBPORT', default=13370,type=int,
help="Bind www server to port. 0 to disable, default: %(default)s")
parser.add_argument("--db",action='store', dest='DB',default='/tmp/nando.sqlite',type=str,
help="Sqlite file for database.")
help="Sqlite file for database: %(default)s")
parser.add_argument("--quiet","-q",action='store_true', dest='quiet',default=False,
help="Quiet operation.")
help="Quiet operation: %(default)s")
options=parser.parse_args()
return options
@@ -192,18 +194,24 @@ def humanize_time(secs):
if __name__ == "__main__":
opts=setup_options()
if not opts.quiet:
print("Starting NandoD {0}:{1}".format(opts.HOST,opts.PORT))
print("Starting NandoD UDP:{0}:{1}, TCP:{0}:{2}".format(
opts.HOST,
opts.PORT,
opts.WEBPORT
))
UDP=threading.Thread(target=UDPserve)
TCP=threading.Thread(target=TCPserve)
UDP.daemon=True
TCP.daemon=True
UDP.start()
TCP.start()
if options.WEBPORT > 0:
TCP=threading.Thread(target=TCPserve)
TCP.daemon=True
TCP.start()
while True:
try:
time.sleep(1)
except KeyboardInterrupt:
print("Exiting..")
server.shutdown()
HTMLserver.shutdown()
if options.WEBPORT > 0:
HTMLserver.shutdown()
sys.exit(0)