Skip to content

Commit

Permalink
Name change ('all-in-one' was taken)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanschelven committed Aug 29, 2024
1 parent 28c1b41 commit bdb1cea
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# All-in-One Process Manager for Docker Containers
# Monofy: Process Manager for Docker Containers

This Python script is designed to manage multiple processes within a single Docker
container, ensuring they are started, monitored, and terminated together.
Expand Down Expand Up @@ -37,15 +37,15 @@ why this is a great idea](https://www.bugsink.com/multi-process-docker-images/)
To use this script, clone the repository or install via your preferred method:

```
pip install allinone
pip install monofy
```

### Usage

You can use this script to start and manage multiple processes in a Docker container.

The commands for the processes and their own arguments should be passed as arguments
should be passed as arguments to `all-in-one`, separated by the literal string `|||`.
should be passed as arguments to `monofy`, separated by the literal string `|||`.

You can also provide "pre commands", one or more commands to run before the parallel
processes are started, usually to perform setup tasks like checking the environment.
Expand All @@ -56,16 +56,16 @@ Such pre-commands should be separated by `&&`.
Launch two commands in parallel, with connected fates (death of one kills the other):

```
all-in-one child-command-1 --param-for-2 '|||' child-command-2 --param-for-2
monofy child-command-1 --param-for-2 '|||' child-command-2 --param-for-2
```

(Note the single quotes around the operators, which ensure they are not parsed by
your shell, but are instead passed on to `all-in-one`)
your shell, but are instead passed on to `monofy`)

Launch some "pre commands" before launching two commands in parallel:

```
all-in-one pre-command-1 --foo=bar '&&' child-command-1 param-for-that '|||' child-command-2 -v
monofy pre-command-1 --foo=bar '&&' child-command-1 param-for-that '|||' child-command-2 -v
```

### Example Dockerfile
Expand All @@ -75,9 +75,9 @@ Here’s how you might use this script in a Dockerfile:
```
FROM [..]
RUN pip install allinone
RUN pip install monofy
CMD ["all-in-one", "check-install", "--deploy", "&&", "web-server", "0.0.0.0:8000", "|||", "background-process", "-v"]
CMD ["monofy", "check-install", "--deploy", "&&", "web-server", "0.0.0.0:8000", "|||", "background-process", "-v"]
```

### Usage outside Docker
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions allinone/scripts/all_in_one.py → monofy/scripts/monofy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self):
The script is written to be able to run multiple OS processes in a single Docker container. It may, however,
be useful in other contexts as well, i.e. for [developer] ergonomics when running in a terminal.
"""
print("all-in-one starting with pid", os.getpid())
print("monofy starting with pid", os.getpid())

self.pre_start()

Expand All @@ -45,7 +45,7 @@ def pre_start(self):
# about signal-handling if you choose the other form.

for args in self.get_pre_start_command_args(sys.argv):
print("all-in-one 'pre-start' process:", " ".join(args))
print("monofy 'pre-start' process:", " ".join(args))
proc = subprocess.run(args)
if proc.returncode != 0:
sys.exit(proc.returncode)
Expand All @@ -57,11 +57,11 @@ def start_children(self):
child = subprocess.Popen(args)
except Exception:
# Print is a bit superflous here, as the exception will be printed anyway by the raise
# print("all-in-one failed to start process:", " ".join(args), "(%s)" % e)
# print("monofy failed to start process:", " ".join(args), "(%s)" % e)
self.terminate_children()
raise

print("all-in-one started process %s:" % child.pid, " ".join(args))
print("monofy started process %s:" % child.pid, " ".join(args))
self.children.append(child)

def terminate_children(self, except_child=None):
Expand Down
18 changes: 9 additions & 9 deletions allinone/tests.py → monofy/tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import unittest

from allinone.scripts.all_in_one import ParentProcess
from monofy.scripts.monofy import ParentProcess


class AllInOneTestCase(unittest.TestCase):
class MonofyTestCase(unittest.TestCase):

def test_arg_parsing(self):
def _check(argv, expected_pre_start, expected_parallel):
Expand All @@ -15,43 +15,43 @@ def _check(argv, expected_pre_start, expected_parallel):
_check(
# this cannot really happen in practice, because we guard for "we need some args". Regardless, we keep the
# test here to show what the parser would do (even if that's a bit weird, i.e. calling a single non-command)
["all_in_one.py"],
["monofy.py"],
[],
[[]],
)

_check(
["all_in_one.py", "a", "b"],
["monofy.py", "a", "b"],
[],
[["a", "b"]],
)

_check(
["all_in_one.py", "a", "b", "|||", "c", "d", "|||", "e", "f"],
["monofy.py", "a", "b", "|||", "c", "d", "|||", "e", "f"],
[],
[["a", "b"], ["c", "d"], ["e", "f"]],
)

_check(
["all_in_one.py", "a", "b", "&&", "c", "d", "|||", "e", "f"],
["monofy.py", "a", "b", "&&", "c", "d", "|||", "e", "f"],
[["a", "b"]],
[["c", "d"], ["e", "f"]],
)

_check(
["all_in_one.py", "a", "b", "|||", "c", "d", "|||", "e", "f"],
["monofy.py", "a", "b", "|||", "c", "d", "|||", "e", "f"],
[],
[["a", "b"], ["c", "d"], ["e", "f"]],
)

_check(
["all_in_one.py", "a", "b", "&&", "c", "d", "&&", "e", "f"],
["monofy.py", "a", "b", "&&", "c", "d", "&&", "e", "f"],
[["a", "b"], ["c", "d"]],
[["e", "f"]],
)

_check(
["all_in_one.py", "a", "b", "&&", "c", "d", "&&", "e", "f", "|||", "g", "h", "|||", "i", "j"],
["monofy.py", "a", "b", "&&", "c", "d", "&&", "e", "f", "|||", "g", "h", "|||", "i", "j"],
[["a", "b"], ["c", "d"]],
[["e", "f"], ["g", "h"], ["i", "j"]],
)
Expand Down
13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
version_file = "allinone/_version.py"
version_file = "monofy/_version.py"

[project]
name = "allinone"
name = "monofy"
authors = [
{name = "Bugsink B.V.", email = "info@bugsink.com"},
]
Expand All @@ -20,20 +20,19 @@ classifiers = [
dynamic = ["version"]

[project.scripts]
allinone = "allinone.scripts.all_in_one:main"
all-in-one = "allinone.scripts.all_in_one:main"
monofy = "monofy.scripts.monofy:main"

[tool.setuptools]
include-package-data = true # this is the default, but explicit is better than implicit

[tool.setuptools.packages.find]
where = ["."]
include = [
"allinone*",
"monofy*",
]

exclude = [] # exclude packages matching these glob patterns (empty by default)

[project.urls]
"Homepage" = "https://github.com/bugsink/allinone"
"Bug Reports" = "https://github.com/bugsink/allinone/issues"
"Homepage" = "https://github.com/bugsink/monofy"
"Bug Reports" = "https://github.com/bugsink/monofy/issues"

0 comments on commit bdb1cea

Please sign in to comment.