Add ordering support
This commit is contained in:
parent
2451baf0bc
commit
a45c01b374
|
@ -20,7 +20,7 @@ let
|
|||
};
|
||||
in
|
||||
rec {
|
||||
/* webapp = rec {
|
||||
webapp = rec {
|
||||
port = 5000;
|
||||
dnsName = "webapp.local";
|
||||
|
||||
|
@ -36,5 +36,5 @@ rec {
|
|||
webapps = [ webapp ];
|
||||
inherit port;
|
||||
} {};
|
||||
};*/
|
||||
};
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ let
|
|||
} overrides.image or {});
|
||||
in
|
||||
createDockerContainer (stdenv.lib.recursiveUpdate {
|
||||
inherit name dockerImage postInstall cmd;
|
||||
inherit name dockerImage postInstall cmd dependencies;
|
||||
dockerImageTag = "${name}:latest";
|
||||
useHostNixStore = true;
|
||||
useHostNetwork = true;
|
||||
|
|
|
@ -26,6 +26,10 @@ let
|
|||
|
||||
priority = if dependencies == [] then 1
|
||||
else builtins.head (builtins.sort (a: b: a > b) (map (dependency: dependency.priority) dependencies)) + 1;
|
||||
|
||||
sequenceNumberToString = number:
|
||||
if number < 10 then "0${toString number}"
|
||||
else toString number;
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name priority;
|
||||
|
@ -44,7 +48,7 @@ stdenv.mkDerivation {
|
|||
) _dockerCreateParameters}
|
||||
EOF
|
||||
|
||||
echo "${toString priority}" > $out/${name}-docker-priority
|
||||
touch $out/${sequenceNumberToString priority}-${name}-docker-priority
|
||||
|
||||
${stdenv.lib.optionalString useHostNixStore ''
|
||||
# Add configuration files with Nix store paths used from the host system so that they will not be garbage collected
|
||||
|
|
|
@ -182,7 +182,7 @@ oldunits=()
|
|||
|
||||
if [ -d "$oldProfilePath" ]
|
||||
then
|
||||
for i in $oldProfilePath/*-docker-settings
|
||||
for i in $oldProfilePath/*-docker-priority
|
||||
do
|
||||
currentPath=$(readlink -f "$i")
|
||||
oldunits+=($currentPath)
|
||||
|
@ -193,7 +193,7 @@ fi
|
|||
|
||||
newunits=()
|
||||
|
||||
for i in $profilePath/*-docker-settings
|
||||
for i in $profilePath/*-docker-priority
|
||||
do
|
||||
currentPath=$(readlink -f "$i")
|
||||
newunits+=($currentPath)
|
||||
|
@ -203,22 +203,24 @@ if [ "$oldProfilePath" != "" ]
|
|||
then
|
||||
# Undeploy obsolete containers
|
||||
|
||||
for i in $oldProfilePath/*-docker-settings
|
||||
for i in $(echo $oldProfilePath/*-docker-priority | sort -r)
|
||||
do
|
||||
if ! containsElement "$(readlink -f "$i")" "${newunits[@]}"
|
||||
then
|
||||
undeployContainer "$(dirname "$i")" "$(basename "$i" -docker-settings)"
|
||||
priorityFile="$(basename "$i" -docker-priority)"
|
||||
undeployContainer "$(dirname "$i")" "${priorityFile:3}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Deploy new containers
|
||||
|
||||
for i in $profilePath/*-docker-settings
|
||||
for i in $profilePath/*-docker-priority
|
||||
do
|
||||
if ! containsElement "$(readlink -f "$i")" "${oldunits[@]}"
|
||||
then
|
||||
deployContainer "$(dirname "$i")" "$(basename "$i" -docker-settings)"
|
||||
priorityFile="$(basename "$i" -docker-priority)"
|
||||
deployContainer "$(dirname "$i")" "${priorityFile:3}"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -143,11 +143,14 @@ fi
|
|||
|
||||
newscripts=()
|
||||
|
||||
for i in $(ls $rcnew/S*)
|
||||
do
|
||||
currentPath=$(readlink -f $i)
|
||||
newscripts+=($currentPath)
|
||||
done
|
||||
if [ -d "$rcnew" ]
|
||||
then
|
||||
for i in $(ls $rcnew/S*)
|
||||
do
|
||||
currentPath=$(readlink -f $i)
|
||||
newscripts+=($currentPath)
|
||||
done
|
||||
fi
|
||||
|
||||
# Create new groups and users
|
||||
createNewGroups
|
||||
|
|
Loading…
Reference in New Issue