Skip to content
This repository has been archived by the owner on Nov 22, 2020. It is now read-only.

Commit

Permalink
add optional subprocess timeout flag, increase default timeout amidaw…
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Sep 30, 2020
1 parent 6d1e08c commit f0d0352
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions winagent/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
local_salt,
local_mesh,
cert,
cmd_timeout,
log_level,
log_to="stdout",
):
Expand All @@ -49,6 +50,7 @@ def __init__(
self.local_salt = local_salt
self.local_mesh = local_mesh
self.cert = cert
self.cmd_timeout = cmd_timeout if cmd_timeout else 900

def install(self):
# check for existing installation and exit if found
Expand Down Expand Up @@ -214,7 +216,9 @@ def install(self):
meshAgent.remove_mesh(exe=mesh)

# install mesh
self.mesh_node_id = meshAgent.install_mesh(exe=mesh)
self.mesh_node_id = meshAgent.install_mesh(
exe=mesh, cmd_timeout=self.cmd_timeout
)

self.logger.debug(f"{self.mesh_node_id=}")
sys.stdout.flush()
Expand Down Expand Up @@ -296,7 +300,7 @@ def install(self):

try:
install_salt = subprocess.run(
salt_cmd, cwd=self.programdir, shell=True, timeout=300
salt_cmd, cwd=self.programdir, shell=True, timeout=self.cmd_timeout
)
except Exception as e:
self.logger.error(e)
Expand Down
6 changes: 4 additions & 2 deletions winagent/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ def remove_mesh(self, exe):
if self.mesh_dir:
remove_dir(self.mesh_dir)

def install_mesh(self, exe):
def install_mesh(self, exe, cmd_timeout):
attempts = 0
retries = 5

print("Installing mesh agent", flush=True)
try:
ret = subprocess.run([exe, "-fullinstall"], capture_output=True, timeout=60)
ret = subprocess.run(
[exe, "-fullinstall"], capture_output=True, timeout=cmd_timeout
)
except Exception as e:
self.logger.error(e)
sys.stdout.flush()
Expand Down
2 changes: 2 additions & 0 deletions winagent/tacticalrmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def main():
parser.add_argument("--api", action="store", dest="api_url", type=str)
parser.add_argument("--client-id", action="store", dest="client_id", type=int)
parser.add_argument("--site-id", action="store", dest="site_id", type=int)
parser.add_argument("--timeout", action="store", dest="cmd_timeout", type=int)
parser.add_argument(
"--desc",
action="store",
Expand Down Expand Up @@ -164,6 +165,7 @@ def main():
local_salt=args.local_salt,
local_mesh=args.local_mesh,
cert=args.cert,
cmd_timeout=args.cmd_timeout,
)

installer.install()
Expand Down

0 comments on commit f0d0352

Please sign in to comment.