Skip to content

Commit

Permalink
add healthchecks.io cron monitoring
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Wamy-Dev committed Apr 26, 2022
1 parent 1e2f0ce commit 1a29da1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions components/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SELENIUMCLIENT=yourseleniumclient
SEARCHCLIENT=yourmeilisearchclient
SEARCHAPIKEY=yourmeilisearchclientapikey
CRONMONITORING=yourhealthcheckspingurl
5 changes: 2 additions & 3 deletions components/grabber.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion components/sendtosearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@
#
SEARCHCLIENT = config('SEARCHCLIENT')
SEARCHAPIKEY = config('SEARCHAPIKEY')
CRONMONITORING = config("CRONMONITORING")
#
#client = meilisearch.Client('serverlocation', 'apikey')
client = meilisearch.Client(SEARCHCLIENT, SEARCHAPIKEY)
json_file = open('./components/outputsearchready.json')
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.')
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.")
10 changes: 9 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1a29da1

Please sign in to comment.