Use '&&' and '|||' in server-unified syntax

This commit is contained in:
Klaas van Schelven
2024-08-29 08:39:34 +02:00
parent 4c38473865
commit b1baa529d4
3 changed files with 13 additions and 14 deletions

View File

@@ -32,4 +32,4 @@ RUN ["bugsink-manage", "migrate", "snappea", "--database=snappea"]
EXPOSE 8000
CMD [ "bugsink-server-unified", "bugsink-manage", "check", "--deploy", "--fail-level", "WARNING", "AMP_AMP", "gunicorn", "--bind=0.0.0.0:8000", "--workers=10", "--access-logfile", "-", "bugsink.wsgi", "UNIFIED_WITH", "bugsink-runsnappea"]
CMD [ "bugsink-server-unified", "bugsink-manage", "check", "--deploy", "--fail-level", "WARNING", "&&", "gunicorn", "--bind=0.0.0.0:8000", "--workers=10", "--access-logfile", "-", "bugsink.wsgi", "|||", "bugsink-runsnappea"]

View File

@@ -83,7 +83,7 @@ class ParentProcess:
@classmethod
def get_pre_start_command_args(self, argv):
"""Splits our own arguments into a list of args for each of the pre-start commands, we split on "AMP_AMP"."""
"""Splits our own arguments into a list of args for each of the pre-start commands, we split on "&&"."""
# We don't want to pass the first argument, as that is the script name
args = argv[1:]
@@ -91,8 +91,8 @@ class ParentProcess:
result = []
this = []
for arg in args:
if arg == "AMP_AMP":
# AMP_AMP serves as a terminator here, i.e. we only add-to-result when we encounter it, the last bit
if arg == "&&":
# && serves as a terminator here, i.e. we only add-to-result when we encounter it, the last bit
# is never addeded (it will be dealt with as the set of parallel commands)
result.append(this)
this = []
@@ -103,17 +103,17 @@ class ParentProcess:
@classmethod
def get_parallel_command_args(self, argv):
"""Splits our own arguments into a list of args for each of the children each, we split on "UNIFIED_WITH"."""
"""Splits our own arguments into a list of args for each of the children each, we split on "|||"."""
# We don't want to pass the first argument, as that is the script name
args = argv[1:]
while "AMP_AMP" in args:
args = args[args.index("AMP_AMP") + 1:]
while "&&" in args:
args = args[args.index("&&") + 1:]
result = [[]]
for arg in args:
if arg == "UNIFIED_WITH":
if arg == "|||":
result.append([])
else:
result[-1].append(arg)

View File

@@ -157,32 +157,31 @@ class ServerUnifiedTestCase(RegularTestCase):
)
_check(
["script.py", "a", "b", "UNIFIED_WITH", "c", "d", "UNIFIED_WITH", "e", "f"],
["script.py", "a", "b", "|||", "c", "d", "|||", "e", "f"],
[],
[["a", "b"], ["c", "d"], ["e", "f"]],
)
_check(
["script.py", "a", "b", "AMP_AMP", "c", "d", "UNIFIED_WITH", "e", "f"],
["script.py", "a", "b", "&&", "c", "d", "|||", "e", "f"],
[["a", "b"]],
[["c", "d"], ["e", "f"]],
)
_check(
["script.py", "a", "b", "UNIFIED_WITH", "c", "d", "UNIFIED_WITH", "e", "f"],
["script.py", "a", "b", "|||", "c", "d", "|||", "e", "f"],
[],
[["a", "b"], ["c", "d"], ["e", "f"]],
)
_check(
["script.py", "a", "b", "AMP_AMP", "c", "d", "AMP_AMP", "e", "f"],
["script.py", "a", "b", "&&", "c", "d", "&&", "e", "f"],
[["a", "b"], ["c", "d"]],
[["e", "f"]],
)
_check(
["script.py", "a", "b", "AMP_AMP", "c", "d", "AMP_AMP",
"e", "f", "UNIFIED_WITH", "g", "h", "UNIFIED_WITH", "i", "j"],
["script.py", "a", "b", "&&", "c", "d", "&&", "e", "f", "|||", "g", "h", "|||", "i", "j"],
[["a", "b"], ["c", "d"]],
[["e", "f"], ["g", "h"], ["i", "j"]],
)