fix: [error] If the port is used, be graceful.

pull/95/head
Steve Clement 2019-05-29 09:09:14 +09:00
parent e74b4a5bff
commit 30cb762ef7
No known key found for this signature in database
GPG Key ID: 69A20F509BE4AEE9
1 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import configparser
import datetime
import errno
import json
import logging
import math
@ -590,4 +591,12 @@ def getGenericTrendingOvertime():
return jsonify(data)
if __name__ == '__main__':
app.run(host=server_host, port=server_port, threaded=True)
try:
app.run(host=server_host,
port=server_port,
threaded=True)
except OSError as error:
if error.errno == 98:
print("\n\n\nAddress already in use, the defined port is: " + str(server_port))
else:
print(str(error))