forked from DGNum/infrastructure
feat(django-apps): allow adding extra init steps
This commit is contained in:
parent
990206da3c
commit
4229835ec4
1 changed files with 19 additions and 4 deletions
|
@ -445,6 +445,15 @@ in
|
|||
doBackups = mkEnableOption "backups for this site" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
extraInit = mkOption {
|
||||
type = lines;
|
||||
description = ''
|
||||
Steps taken during the initialization after the migration is done
|
||||
and the static files have been collected.
|
||||
'';
|
||||
default = '''';
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
|
@ -722,18 +731,24 @@ in
|
|||
inherit after environment path;
|
||||
|
||||
preStart = ''
|
||||
# Create the necessary directory with the correct user/group
|
||||
mkdir -p ${config.mediaDirectory} ${config.staticDirectory}
|
||||
|
||||
if [ ! -f .initialized ]; then
|
||||
# The previous initialization might have failed, so restart from the beginning
|
||||
rm -rf source
|
||||
|
||||
# We need to download the application source and run the migrations first
|
||||
${lib.getExe pkgs.git} clone --single-branch --branch ${config.branch} ${config.source} source
|
||||
(cd source && python ${config.managePath} migrate --no-input && python ${config.managePath} collectstatic --no-input)
|
||||
pushd source
|
||||
python ${config.managePath} migrate --no-input
|
||||
python ${config.managePath} collectstatic --no-input
|
||||
|
||||
${config.extraInit}
|
||||
|
||||
popd
|
||||
touch .initialized
|
||||
fi
|
||||
|
||||
# Create the necessary directory with the correct user/group
|
||||
mkdir -p ${config.mediaDirectory} ${config.staticDirectory}
|
||||
'';
|
||||
|
||||
requires = optional (config.application.type != "daphne") "dj-${name}.socket";
|
||||
|
|
Loading…
Add table
Reference in a new issue