From 1a29da107b81aa640432336bc0a459a0dcc6dabf Mon Sep 17 00:00:00 2001 From: David <25761442+Wamy-Dev@users.noreply.github.com> Date: Mon, 25 Apr 2022 22:28:44 -0500 Subject: [PATCH] add healthchecks.io cron monitoring sends a ping when it is done with the entire process, and checks if the cron did its job. Ive just been suspicious of it lately. --- CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md | 0 components/.env | 1 + components/grabber.py | 5 ++--- components/sendtosearch.py | 10 +++++++++- main.py | 10 +++++++++- 5 files changed, 21 insertions(+), 5 deletions(-) rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (100%) diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/components/.env b/components/.env index 388d656..850608a 100644 --- a/components/.env +++ b/components/.env @@ -1,3 +1,4 @@ SELENIUMCLIENT=yourseleniumclient SEARCHCLIENT=yourmeilisearchclient SEARCHAPIKEY=yourmeilisearchclientapikey +CRONMONITORING=yourhealthcheckspingurl \ No newline at end of file diff --git a/components/grabber.py b/components/grabber.py index 7a11680..20d7c9d 100644 --- a/components/grabber.py +++ b/components/grabber.py @@ -16,7 +16,6 @@ from os import getcwd # SELENIUMCLIENT = config('SELENIUMCLIENT') -#starting timer print('starting process') #getting updated input file url = "https://raw.githubusercontent.com/Wamy-Dev/ReziWebsite/main/Input%20Data.txt" @@ -33,8 +32,8 @@ chrome_options.add_extension('./resources/popupblockerpro.crx') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage') -chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36") -#wd = uc.Chrome(executable_path='./resources/chromedriver',options=chrome_options) #if local +chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36") +#wd = uc.Chrome(executable_path='./resources/chromedriver',options=chrome_options) #if local, make sure wd = uc.Remote(SELENIUMCLIENT, options=chrome_options) #if for remote json_data={} #getting the links and setting up json diff --git a/components/sendtosearch.py b/components/sendtosearch.py index 50d5eea..f280668 100644 --- a/components/sendtosearch.py +++ b/components/sendtosearch.py @@ -6,6 +6,7 @@ # SEARCHCLIENT = config('SEARCHCLIENT') SEARCHAPIKEY = config('SEARCHAPIKEY') +CRONMONITORING = config("CRONMONITORING") # #client = meilisearch.Client('serverlocation', 'apikey') client = meilisearch.Client(SEARCHCLIENT, SEARCHAPIKEY) @@ -13,4 +14,11 @@ games = json.load(json_file) client.delete_index('games') #deletes previous index due to the way meilisearch does indexes, it adds on top of, and updating doesn't work very well, so a good ole delete and create works fine. client.index('games').add_documents(games) -print('finished entire process.') \ No newline at end of file +print('finished entire process.') +# +try: + now=datetime.now() + current_time = now.strftime("%H:%M:%S") + requests.post(CRONMONITORING, data=f'Time finished: {current_time}.') +except: + print("Cannot send ping.") \ No newline at end of file diff --git a/main.py b/main.py index 1667d3d..65b23cf 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,15 @@ # / /_/ / _ \/_ / / / # / _, _/ __/ / /_/ / #/_/ |_|\___/ /___/_/ -#Rezi was written in Python 3.9.6 on Selenium. +#Rezi was written in Python 3.9.6 on Sublime Text. +#Please visit the github at https://github.com/Wamy-Dev/ReziWebsite +import requests import sys +from datetime import datetime sys.path.append('./components') +# +now=datetime.now() +current_time = now.strftime("%H:%M:%S") +print(f"Time started: {current_time}.") +# import grabber \ No newline at end of file