From 8eded9ecb6220bb26599419a4aaea1743d3d187e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 21 Apr 2019 19:31:06 +0200 Subject: Move cache clearing of php applications to preStart systemd --- nixops/modules/websites/piedsjaloux/piedsjaloux.nix | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'nixops/modules/websites/piedsjaloux/piedsjaloux.nix') diff --git a/nixops/modules/websites/piedsjaloux/piedsjaloux.nix b/nixops/modules/websites/piedsjaloux/piedsjaloux.nix index 1c7e983..87699db 100644 --- a/nixops/modules/websites/piedsjaloux/piedsjaloux.nix +++ b/nixops/modules/websites/piedsjaloux/piedsjaloux.nix @@ -28,6 +28,18 @@ let ''; }; phpFpm = rec { + preStart = '' + if [ ! -f "${varDir}/currentWebappDir" -o \ + ! -f "${varDir}/currentKey" -o \ + "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \ + || ! sha512sum -c --status ${varDir}/currentKey; then + pushd ${webappDir} > /dev/null + /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup + popd > /dev/null + echo -n "${webappDir}" > ${varDir}/currentWebappDir + sha512sum /run/keys/webapps/${environment}-piedsjaloux > ${varDir}/currentKey + fi + ''; serviceDeps = [ "mysql.service" "${environment}-piedsjaloux-key.service" ]; socket = "/var/run/phpfpm/piedsjaloux-${environment}.sock"; pool = '' @@ -130,13 +142,6 @@ let install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ ${varDir}/tmp install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions - if [ ! -f "${varDir}/currentWebappDir" -o \ - "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then - pushd ${webappDir} > /dev/null - $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup - popd > /dev/null - echo -n "${webappDir}" > ${varDir}/currentWebappDir - fi ''; }; webappDir = composerEnv.buildPackage ( -- cgit v1.2.3