mirror of
https://github.com/blw1138/cross-py-builder.git
synced 2025-12-17 08:38:11 +00:00
Remove buggy existing process code
This commit is contained in:
@@ -18,7 +18,7 @@ import platform
|
||||
from zeroconf_server import ZeroconfServer
|
||||
from version import APP_VERSION, APP_NAME
|
||||
|
||||
build_agent_version = "0.1.32"
|
||||
build_agent_version = "0.1.33"
|
||||
|
||||
app = Flask(__name__)
|
||||
launch_time = datetime.datetime.now()
|
||||
@@ -352,35 +352,8 @@ def delete_cache():
|
||||
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__":
|
||||
|
||||
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}) =====")
|
||||
ZeroconfServer.configure("_crosspybuilder._tcp.local.", socket.gethostname(), 9001)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user