Remove buggy existing process code

This commit is contained in:
Brett Williams
2025-03-06 14:57:39 -06:00
parent 0f487640bd
commit a568b5140b

View File

@@ -18,7 +18,7 @@ import platform
from zeroconf_server import ZeroconfServer from zeroconf_server import ZeroconfServer
from version import APP_VERSION, APP_NAME from version import APP_VERSION, APP_NAME
build_agent_version = "0.1.32" build_agent_version = "0.1.33"
app = Flask(__name__) app = Flask(__name__)
launch_time = datetime.datetime.now() launch_time = datetime.datetime.now()
@@ -352,35 +352,8 @@ def delete_cache():
return jsonify(job_cache()), 200 return jsonify(job_cache()), 200
def is_another_instance_running():
if os.name == "nt": # Windows
cmd = [
"powershell",
"-Command",
"Get-WmiObject Win32_Process | Where-Object { $_.CommandLine -match 'python' } | Select-Object ProcessId, CommandLine"
]
minimum_count = 1
else:
cmd = ["pgrep", "-fl", " "]
minimum_count = 0
try:
output = subprocess.check_output(cmd, text=True)
running_versions = []
for line in output.splitlines():
if SCRIPT_PATH in line and str(os.getpid()) not in line:
running_versions.append(line)
return len(running_versions) > minimum_count
except subprocess.CalledProcessError:
return False
if __name__ == "__main__": if __name__ == "__main__":
had_previous_instances = False
while is_another_instance_running():
had_previous_instances = True
print("Another instance is running. Waiting until it exits.")
time.sleep(1)
print(f"===== {APP_NAME} {APP_VERSION} Build Agent (v{build_agent_version}) =====") print(f"===== {APP_NAME} {APP_VERSION} Build Agent (v{build_agent_version}) =====")
ZeroconfServer.configure("_crosspybuilder._tcp.local.", socket.gethostname(), 9001) ZeroconfServer.configure("_crosspybuilder._tcp.local.", socket.gethostname(), 9001)
try: try: