some helps. separate port for tcp
This commit is contained in:
26
nandod
26
nandod
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user