Skip to content

Commit

Permalink
minor tweaks for the changes for start/restart exiting logs after sta…
Browse files Browse the repository at this point in the history
…rtup is "finished". for cisagov#241 and cisagov#240.
  • Loading branch information
mmguero committed Feb 27, 2023
1 parent 2177413 commit 9248f78
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scripts/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from malcolm_common import *
from base64 import b64encode
from collections import defaultdict, namedtuple
from subprocess import PIPE, STDOUT, Popen, check_call, CalledProcessError
from subprocess import PIPE, DEVNULL, Popen, TimeoutExpired
from urllib.parse import urlparse

try:
Expand Down Expand Up @@ -492,6 +492,7 @@ def logs():
][: 8 if args.service is not None else -1],
env=osEnv,
stdout=PIPE,
stderr=None if args.debug else DEVNULL,
)
while True:
output = process.stdout.readline()
Expand All @@ -502,7 +503,11 @@ def logs():
outputStrEscaped = EscapeAnsi(outputStr)
if ignoreRegEx.match(outputStrEscaped):
pass ### print(f'!!!!!!!: {outputStr}')
elif finishedStartingRegEx.match(outputStrEscaped) and (args.cmdStart or args.cmdRestart):
elif (
(args.cmdStart or args.cmdRestart)
and (not args.cmdLogs)
and finishedStartingRegEx.match(outputStrEscaped)
):
finishedStarting = True
else:
serviceMatch = serviceRegEx.search(outputStrEscaped)
Expand Down Expand Up @@ -625,9 +630,13 @@ def logs():

if finishedStarting:
process.terminate()
try:
process.wait(timeout=5.0)
except TimeoutExpired:
process.kill()
# # TODO: Replace 'localhost' with an outwards-facing IP since I doubt anybody is
# accessing these from the Malcolm server.
print("Started Malcolm\n\n")
print("\nStarted Malcolm\n\n")
print("Malcolm services can be accessed via the following URLs:")
print("------------------------------------------------------------------------------")
print(" - Arkime: https://localhost/")
Expand Down

0 comments on commit 9248f78

Please sign in to comment.