Skip to content

Commit 66f3c4a

Browse files
committed
fixes
1 parent 9e00188 commit 66f3c4a

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

bota/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_description():
5454
#
5555
# This field corresponds to the "Description" metadata field:
5656
# https://packaging.python.org/specifications/core-metadata/#description-optional
57-
version='4.0.106',
57+
version='4.0.112',
5858
author="Chetan Jain",
5959
author_email="[email protected]",
6060
description="CLI for botasaurus.",

bota/src/bota/vm.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,23 @@ def get_filename_from_url(url):
491491
from urllib.parse import urlparse
492492
return os.path.basename(urlparse(url).path.rstrip("/"))
493493

494+
def kill_process(name):
495+
# Ask user for the name of process
496+
import os, signal
497+
try:
498+
# iterating through each instance of the process
499+
for line in os.popen(f'ps ax | grep "usr/bin/{name}" | grep -v grep'):
500+
fields = line.split()
501+
502+
# extracting Process ID from the output
503+
pid = fields[0]
504+
505+
# terminating process
506+
os.kill(int(pid), signal.SIGKILL)
507+
print("Killing",pid)
508+
except:
509+
print("Error Encountered while running script")
510+
494511
def install_desktop_app_in_vm(
495512
debian_installer_url,
496513
port,
@@ -514,7 +531,8 @@ def install_desktop_app_in_vm(
514531

515532
subprocess.run(["wget", debian_installer_url], check=True, stderr=subprocess.STDOUT)
516533
package_name = subprocess.check_output(f"dpkg-deb -f ./{default_name} Package", shell=True).decode().strip()
517-
if is_package_installed(package_name):
534+
is_already_installed = is_package_installed(package_name)
535+
if is_already_installed:
518536
install_command = f"sudo dpkg -i ./{default_name}"
519537
else:
520538
install_command = f"sudo apt --fix-broken install ./{default_name} -y"
@@ -547,15 +565,14 @@ def install_desktop_app_in_vm(
547565
User={uname}
548566
Environment="DISPLAY=:99"
549567
ExecStart=/usr/bin/{package_name} --only-start-api --port {port} {'--api-base-path ' + api_base_path if api_base_path else ''}
550-
Restart=on-failure
551-
RestartSec=10
568+
Restart=always
569+
RestartSec=1
552570
[Install]
553571
WantedBy=multi-user.target"""
554572
write_file_sudo(package_service_content, f"/etc/systemd/system/{package_service_name}")
555573

556574
if not skip_apache_request_routing:
557575
setup_apache_load_balancer_desktop_app(port, api_base_path)
558-
559576
# Enable and start services
560577
systemctl_commands = f"""
561578
sudo systemctl daemon-reload
@@ -570,6 +587,9 @@ def install_desktop_app_in_vm(
570587
sudo systemctl restart apache2"""
571588
subprocess.run(remove_empty_lines(systemctl_commands), shell=True, check=True, stderr=subprocess.STDOUT)
572589

590+
if is_already_installed:
591+
kill_process(package_name)
592+
573593
click.echo("Successfully installed the Desktop App.")
574594
click.echo("Now, Checking API Status...")
575595

0 commit comments

Comments
 (0)