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/tellesflorian/default.nix | 1 + .../modules/websites/tellesflorian/tellesflorian.nix | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'nixops/modules/websites/tellesflorian') diff --git a/nixops/modules/websites/tellesflorian/default.nix b/nixops/modules/websites/tellesflorian/default.nix index 171d2e7..9bf4a48 100644 --- a/nixops/modules/websites/tellesflorian/default.nix +++ b/nixops/modules/websites/tellesflorian/default.nix @@ -18,6 +18,7 @@ in { config = lib.mkIf cfg.integration.enable { deployment.keys = tellesflorian_dev.keys; security.acme.certs."eldiron".extraDomains."app.tellesflorian.com" = null; + services.myPhpfpm.preStart.tellesflorian_dev = tellesflorian_dev.phpFpm.preStart; services.myPhpfpm.serviceDependencies.tellesflorian_dev = tellesflorian_dev.phpFpm.serviceDeps; services.myPhpfpm.poolConfigs.tellesflorian_dev = tellesflorian_dev.phpFpm.pool; system.activationScripts.tellesflorian_dev = tellesflorian_dev.activationScript; diff --git a/nixops/modules/websites/tellesflorian/tellesflorian.nix b/nixops/modules/websites/tellesflorian/tellesflorian.nix index a8e741e..ba46c0c 100644 --- a/nixops/modules/websites/tellesflorian/tellesflorian.nix +++ b/nixops/modules/websites/tellesflorian/tellesflorian.nix @@ -24,6 +24,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}-tellesflorian > ${varDir}/currentKey + fi + ''; serviceDeps = [ "mysql.service" "${environment}-tellesflorian-passwords-key.service" @@ -141,13 +153,6 @@ let install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ ${varDir}/var 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