Skip to content

Commit

Permalink
20190703
Browse files Browse the repository at this point in the history
  • Loading branch information
sohwaje committed Jul 3, 2019
1 parent cea8a3a commit 431ae11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions simply_socket_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@ def main():
except socket.error as e:
print("Error creating socket : %s" % e)
sys.exit(1)
#return False


#두번째 try-except block : 주어진 host/port로 연결 시도

try:
s.connect((host, port))
print("Success %s" % host)
#if True:
#return True
except socket.gaierror as e:
print("Address-related error connecting to server: %s" % e)
sys.exit(1)
#return False
except socket.error as e:
print("Connection error: %s" % e)
sys.exit(1)
#return False


#세번째 try-except block : 데이터 보내기 시도
Expand All @@ -57,6 +62,7 @@ def main():
# sys.exit(1)
# if not len(buf):
# break
#전달받은 데이터를 표준 출력으로 내보낸다.
# sys.stdout.write(buf)

if __name__ == '__main__':
Expand Down
15 changes: 11 additions & 4 deletions site_alive_check_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@ def send(chat):
"""
URL Alive 체크 함수
"""
#def GET_URL_ALIVE_CHECK(url): # 이 코드 블록은 테스트가 더 필요하다.
# try:
# res = requests.get(url, timeout=2)
# if res.status_code == requests.codes.ok:
# return True
# except (requests.RequestException, requests.ConnectionError) as e:
# return False

def GET_URL_ALIVE_CHECK(url):
try:
res = requests.get(url, timeout=2)
if res.status_code == requests.codes.ok:
res = urllib.request.urlopen(url, timeout=3)
if True:
return True
except (requests.RequestException, requests.ConnectionError) as e:
except (urllib.request.URLError) as e:
return False

"""
현재 URL 서비스 상태 저장
"""
Expand Down

0 comments on commit 431ae11

Please sign in to comment.