forked from indymedia/epicyon
Check if port is already used
parent
8ac9a43b29
commit
0277b309d9
|
@ -147,6 +147,7 @@ from shares import outboxUndoShareUpload
|
|||
from shares import addShare
|
||||
from shares import removeShare
|
||||
from shares import expireShares
|
||||
from utils import isPortInUse
|
||||
from utils import removeAvatarFromCache
|
||||
from utils import locatePost
|
||||
from utils import getCachedPostFilename
|
||||
|
@ -5481,6 +5482,11 @@ def runDaemon(mediaInstance: bool,maxRecentPosts: int, \
|
|||
pubHandler = partial(PubServerUnitTest)
|
||||
else:
|
||||
pubHandler = partial(PubServer)
|
||||
|
||||
if isPortInUse(proxyPort):
|
||||
print('Process is already running on port '+str(proxyPort))
|
||||
return False
|
||||
|
||||
try:
|
||||
httpd = ThreadingHTTPServer(serverAddress, pubHandler)
|
||||
except Exception as e:
|
||||
|
|
7
utils.py
7
utils.py
|
@ -11,6 +11,13 @@ import time
|
|||
import shutil
|
||||
import datetime
|
||||
import json
|
||||
import socket
|
||||
|
||||
def isPortInUse(portNumber: int) -> bool:
|
||||
"""Returns true if the port is in use
|
||||
"""
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
return s.connect_ex(('localhost', portNumber)) == 0
|
||||
|
||||
def removeAvatarFromCache(baseDir: str,actorStr: str) -> None:
|
||||
"""Removes any existing avatar entries from the cache
|
||||
|
|
Loading…
Reference in New Issue