Invoke BSD rc scripts from compound process, document interactive multi-process containers, remove obsolete check for loading Docker images
This commit is contained in:
parent
b0da46b268
commit
cd0f384b9b
17
README.md
17
README.md
|
@ -847,6 +847,7 @@ createMultiProcessImage {
|
|||
tag = "test";
|
||||
exprFile = ../webapps-agnostic/processes.nix;
|
||||
processManager = "supervisord"; # sysvinit, disnix are also valid options
|
||||
interactive = true; # the default option
|
||||
forceDisableUserChange = false; # the default option
|
||||
}
|
||||
```
|
||||
|
@ -860,6 +861,11 @@ with the following parameters:
|
|||
process instances (as shown earlier)
|
||||
* The `processManager` parameter allows you to pick a process manager.
|
||||
Currently, all the options shown above are supported.
|
||||
* We can also specify whether we want to use the container interactively
|
||||
with the `interactive` parameter (which defaults to: `true`). When
|
||||
this setting has been enabled, a `.bashrc` will be configured to make
|
||||
the bash shell usable, and a number of additional packages will be installed
|
||||
for file and process management operations.
|
||||
* It is also possible to adjust the state settings in the processes model.
|
||||
With `forceDisableUserChange` we can disable user creation and user
|
||||
switching. It is also possible to control the other state variables, such
|
||||
|
@ -886,7 +892,16 @@ We can deploy a container instance from the image in interactive mode as
|
|||
follows:
|
||||
|
||||
```bash
|
||||
$ docker run --rm --network host -it multiprocess:test
|
||||
$ docker run --name mycontainer --rm --network host -it multiprocess:test
|
||||
```
|
||||
|
||||
When interactive mode has been enabled, you should be able to "connect" to
|
||||
a container in which you can execute shell commands, for example to control
|
||||
the life-cycle of the sub processes:
|
||||
|
||||
```
|
||||
$ docker exec -it mycontainer /bin/bash
|
||||
$ ps aux
|
||||
```
|
||||
|
||||
Examples
|
||||
|
|
|
@ -29,13 +29,15 @@ let
|
|||
else if processManager == "disnix" then import ./generate-disnix-args.nix {
|
||||
inherit pkgs system exprFile stateDir runtimeDir logDir cacheDir tmpDir forceDisableUserChange extraParams;
|
||||
}
|
||||
# TODO: bsdrc -> similar to above
|
||||
else if processManager == "bsdrc" then import ./generate-bsdrc-args.nix {
|
||||
inherit pkgs system exprFile stateDir runtimeDir logDir cacheDir tmpDir forceDisableUserChange extraParams;
|
||||
}
|
||||
else if processManager == "supervisord" then import ./generate-supervisord-args.nix {
|
||||
inherit pkgs system name compoundLogDir compoundRuntimeDir exprFile stateDir runtimeDir cacheDir logDir tmpDir forceDisableUserChange extraParams;
|
||||
}
|
||||
|
||||
# TODO: docker?
|
||||
# We can't embed launchd, cygrunsrv, because these cannot be managed by anything else
|
||||
# We can't embed launchd, cygrunsrv, because these supervisor processes cannot be managed by anything else
|
||||
# Managing docker containers does not make sense
|
||||
# In theory, systemd could work in containers, but workarounds need to be applied, e.g. cgroup permissions
|
||||
|
||||
else throw "Unsupported process manager: ${processManager}";
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
{ pkgs, system
|
||||
, exprFile
|
||||
, stateDir
|
||||
, runtimeDir
|
||||
, logDir
|
||||
, cacheDir
|
||||
, tmpDir
|
||||
, forceDisableUserChange
|
||||
, extraParams
|
||||
}:
|
||||
|
||||
let
|
||||
generateCompoundProxyScript = import ./generate-compound-proxy.nix {
|
||||
inherit (pkgs) stdenv writeTextFile;
|
||||
};
|
||||
|
||||
profile = import ../create-managed-process/bsdrc/build-bsdrc-env.nix {
|
||||
inherit pkgs system exprFile stateDir runtimeDir cacheDir logDir tmpDir forceDisableUserChange extraParams;
|
||||
};
|
||||
|
||||
tools = (import ../../tools { inherit pkgs system; }).bsdrc;
|
||||
|
||||
proxyScript = generateCompoundProxyScript {
|
||||
startCommand = "${tools}/bin/nixproc-bsdrc-runactivity start ${profile}";
|
||||
stopCommand = "${tools}/bin/nixproc-bsdrc-runactivity -r stop ${profile}";
|
||||
};
|
||||
in
|
||||
{ foregroundProcess = proxyScript;
|
||||
}
|
|
@ -77,11 +77,8 @@ deployContainer()
|
|||
source $configDir/$containerName-docker-settings
|
||||
dockerContainerName="nixproc-$containerName"
|
||||
|
||||
# Load the Docker image if it does not exists
|
||||
if [ "$(docker images -f "reference=$dockerImageTag" | wc -l)" = "1" ]
|
||||
then
|
||||
docker load -i $dockerImage
|
||||
fi
|
||||
# Load the Docker image (this operation is already idempotent)
|
||||
docker load -i $dockerImage
|
||||
|
||||
# Create the container if it does not exists yet
|
||||
if [ "$(docker ps -a -f "name=$dockerContainerName\$" | wc -l)" = "1" ]
|
||||
|
|
Loading…
Reference in New Issue