update
This commit is contained in:
@@ -3,10 +3,10 @@ Check if the main loop is running
|
||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/tests/check_running.py
|
||||
'''
|
||||
import psutil
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
def is_script_running(script_name):
|
||||
"""Check if a given Python script is running."""
|
||||
"""Check if a given Python script is currently running."""
|
||||
for process in psutil.process_iter(['pid', 'cmdline']):
|
||||
if process.info['cmdline'] and script_name in " ".join(process.info['cmdline']):
|
||||
return True # Script is running
|
||||
@@ -14,7 +14,14 @@ def is_script_running(script_name):
|
||||
|
||||
script_to_check = "/var/www/nebuleair_pro_4g/loop/SARA_send_data_v2.py"
|
||||
|
||||
if is_script_running(script_to_check):
|
||||
print(f"{script_to_check} is still running.❌❌❌")
|
||||
else:
|
||||
print(f"{script_to_check} is NOT running.✅✅✅")
|
||||
# Determine script status
|
||||
is_running = is_script_running(script_to_check)
|
||||
|
||||
# Create JSON response
|
||||
response = {
|
||||
"message": "The script is still running.❌❌❌" if is_running else "The script is NOT running.✅✅✅",
|
||||
"running": is_running
|
||||
}
|
||||
|
||||
# Print JSON output
|
||||
print(json.dumps(response, indent=4)) # Pretty print for readability
|
||||
|
||||
Reference in New Issue
Block a user