]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/piedsjaloux/builder.nix
Add phpFpm prestart script to lib
[perso/Immae/Config/Nix.git] / modules / private / websites / piedsjaloux / builder.nix
index 9fcc8fb684b914ccdd362a22c114315cfb6b24b1..d9a78b3b7e64e3221c0582432d1df388cfa20131 100644 (file)
@@ -1,4 +1,4 @@
-{ apacheUser, apacheGroup, piedsjaloux, config, pkgs, lib, texlive, imagemagick }:
+{ apacheUser, apacheGroup, piedsjaloux, config, pkgs, lib, mylibs, texlive, imagemagick }:
 rec {
   app = piedsjaloux.override { inherit (config) environment; };
   varDir = "/var/lib/piedsjaloux_${app.environment}";
@@ -27,18 +27,16 @@ rec {
     '';
   }];
   phpFpm = rec {
-    preStart = ''
-      if [ ! -f "${app.varDir}/currentWebappDir" -o \
-          ! -f "${app.varDir}/currentKey" -o \
-          "${app}" != "$(cat ${app.varDir}/currentWebappDir 2>/dev/null)" ] \
-          || ! sha512sum -c --status ${app.varDir}/currentKey; then
-        pushd ${app} > /dev/null
-        /run/wrappers/bin/sudo -u ${apacheUser} ./bin/console --env=${app.environment} cache:clear --no-warmup
-        popd > /dev/null
-        echo -n "${app}" > ${app.varDir}/currentWebappDir
-        sha512sum /var/secrets/webapps/${app.environment}-piedsjaloux > ${app.varDir}/currentKey
-      fi
-      '';
+    preStart = mylibs.phpFpmPreStart {
+      inherit app;
+      inherit (app) varDir;
+      keyFiles = [
+        "/var/secrets/webapps/${app.environment}-piedsjaloux"
+      ];
+      actions = [
+        "/run/wrappers/bin/sudo -u ${apacheUser} ./bin/console --env=${app.environment} cache:clear --no-warmup"
+      ];
+    };
     serviceDeps = [ "mysql.service" ];
     socket = "/var/run/phpfpm/piedsjaloux-${app.environment}.sock";
     pool = ''