From 7cddc059b5f053f6cc8ddbd8681fbe59de35ddde Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 25 Aug 2023 11:56:06 +1000 Subject: [PATCH] worker: Fixed count sites function --- worker/main.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/worker/main.py b/worker/main.py index ea978d5..cdb9c62 100644 --- a/worker/main.py +++ b/worker/main.py @@ -67,16 +67,11 @@ def ping(): return 'pong' def get_sites_count(): - # If file doesn't exist, create it - try: - sites_file = open('sites.txt', 'r') - except FileNotFoundError: - sites_file = open('sites.txt', 'w') - sites_file.close() - sites_file = open('sites.txt', 'r') - print(sites_file.readlines()) + # Get number of files in nginx/sites + dir = os.listdir('/etc/nginx/sites-available') + num_Sites = len(dir) - 1 # Return number of lines in file - return len(sites_file.readlines()) + return num_Sites def site_exists(domain): # If file doesn't exist, create it